Skip to content

Fix linalg.norm with ord=numpy.inf - #10655

Closed
the-master-guy wants to merge 1 commit into
numpy:masterfrom
the-master-guy:3763
Closed

the-master-guy wants to merge 1 commit into
numpy:masterfrom
the-master-guy:3763

Conversation

@the-master-guy

Copy link
Copy Markdown

Fixed the error where linalg.norm with ord=numpy.inf does not work for empty array, with the solution specified inte the comments, namely creating a case that checks for such a possibility and returns the norm to be 0 as is should be for empty arrays.

@eric-wieser

Copy link
Copy Markdown
Member

with the solution specified inte the comments,

Which comments?

Comment thread numpy/linalg/linalg.py
x = asarray(x)

if x.size == 0:
return 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is too early - it allows np.linalg.norm([], axis="I have no idea what I'm doing"), which should clearly error

@eric-wieser eric-wieser left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tests too

@eric-wieser

Copy link
Copy Markdown
Member

Duplicate of #10688

@eric-wieser eric-wieser marked this as a duplicate of #10688 Mar 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants