-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
svd requires positive-size matrices #5419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Seems reasonable, though if full_matrices=True then one has to decide what (BTW, max([]) is an error.) On Sat, Jan 3, 2015 at 5:37 PM, argriffing notifications@github.com wrote:
Nathaniel J. Smith |
Yep, just noticed that. |
We explicitly forbid it mostly because 1. our gufunc stuff doesn't handle it (which is easy to fix, I got the PR ready mostly) and 2. at least not all lapacks can handle it. If the math is clear about the definition I think we can just special case it. |
Just wanted to clarify regarding
Is this expected behavior ? because this is a cause for some of the exceptions mentioned in #5420 . |
Yes, it is expected. There is no reasonable definition of a maximum from an empty sequence. You could argue it is -inf, but -inf is a rather special beast in any case. |
@seberg , Thanks. Yeah, there isn't a proper definition, but raising an exception means the other codes which use these utility functions, like |
Sure. We are forcing our users to think about what is correct and explicitly handle it when we cannot say it for sure, and we have to do it ourselves :). The fact is, very old numpy versions or even numeric didn't have a very clear handling of these cases I think, so in some places the special cases may still be missing or even be incorrect/weird, though I think numpy is mostly clean by now when it comes to empty arrays. |
@seberg , thanks for the response :) Yeah, numpy is clean in most of the places when it comes to empty arrays. Just wanted to know if the exception in |
Sorry for having parenthetically mentioned |
@argriffing Sorry, It's me who has diverted the discussion. I was just querying about the behavior of different functions on zero sized arrays, which I found when going through gh-5420 |
So just to note. If this interests anyone, gh-3861 was the PR I mentioned before, and I think what is mostly needed for it is to clean up all those empty array cases in linalg (since linalg is the biggest user of gufuncs). |
Related: #8654 |
Fixed in #11424 |
If I'm using svd to help compute the norm of a matrix by looking at its singular values, then I want a size-0 matrix to have a length-0 sequence of singular values whose aggregate function (e.g.
max, sum) will be 0. But numpy explicitly forbids empty inputs with_assertNoEmpty2d(a)
.The text was updated successfully, but these errors were encountered: