-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
ENH,DOC: np.max of a zero-sized array throws a ValueError #22497
Comments
This is by design; what would you expect instead? |
I suppose you could make the argument that it should return |
On the face of it, From a user perspective, it would be best if these zero-sized arrays were either not allowed at all (raise on construction?) or behave consistently (for some definition of being consistent). The latter expectation is nicely expressed by Warren in scipy/scipy#17241 (comment). Otherwise, they regularly need to be special-cased in user code. OTOH, this is all a minor annoyance anyway, and workarounds are not too difficult. Cf scipy/scipy#17305 for a typical example (this is just a recent one out of I don't remember how many; the gut feeling is that this corner case shows up "rarely but regularly", but I've no hard data). |
This has been discussed a few times, I have no strong opinion either way. Also maybe a bit discussed here. Just to be sure you are aware, you can also pass |
Oh thanks, was not aware of the A minor gripe is that this sentence is not very discoverable unless already known. Not that I have a good actionable suggestion though. Using |
Well, for a long time it might have been a bit trick to have -inf as an identity. That would change after gh-20970. |
Describe the issue:
np.max
of a zero-sized array throws a ValueErrorReproduce the code example:
Error message:
NumPy/Python version information:
In [8]: np.version
Out[8]: '1.21.1'
Context for the issue:
Seen as a part of scipy/scipy#17241 (comment). Can be worked around of course, am just reporting that it needs a workaround.
The text was updated successfully, but these errors were encountered: