-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH: show an warning when np.maximum received more than two inputs #27639
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
Agreed, the error message is misleading.
Its signature, like all ufuncs, is
Changing the ufunc signature to be kwd-only would be a large backward incompatible change. Maybe we could do it via a deprecation process. |
I would be up for slowly deprecating not using I would not be surprised if part of the reason for it not being kwarg-only, is that the speed difference between keyword and non-keyword use, used to be much bigger. The actual change required is very contained, but in C (and of course it needs tests and tracking down the EDIT: This is very sprintable/attackable as such. There may be a longer tail of test fixes because we probably use the pattern internally. And at this time, consensus for the change has not been fully established. |
I agree we should encourage keyword |
I'm also in favor of getting rid of the positional To illustrate, ufuncs with 2 inputs and 2 outputs currently require 13 overloads, and it doesn't even take the NEP 50 promotion rules into account yet, which would at least quadruple that (i.e. >=52 overloads): https://github.com/numpy/numtype/blob/1155b2582ab747dc7fcc71736a90912d650a5332/src/numpy-stubs/_core/umath.pyi#L1052-L1222 Now, given this combinatorial mess, try and imagine what the ufunc definition for So to make long story short: Keyword-only |
Yeah, I think when I wrote it, I didn't think too much about how much code may actually be passing I honestly still like our old philosophy of just refusing to type undesired patterns. Also because that is an additional way to nudge users away from it. If we wish we would deprecate it one day (even if we may hesitate to do it), then not typing it feels very reasonable (maybe with docs to have at least some basis for that choice...). |
Proposed new feature or change:
it would be good to show an warning when np.maximum received more than two inputs, otherwise ppl(like me) may think it supports multiple inputs, and spend a lot of time trying to figure out whats wrong
The text was updated successfully, but these errors were encountered: