-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Missing ufuncs: np.divmod and np.positive #8932
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
Hmm, |
divmod ends up dispatching to the div and mod ufuncs, doesn't it? And pos
is a unary operation that just returns a copy so a workaround would be for
the mixin class to define __pos__ to call self.copy().
(Not expressing an opinion on the best solution, just thinking about the
space of options.)
|
Right, because some people still do So probably
That's right. So it probably does the right thing most of the time.
Yes, that would certainly work. |
One downside of the current unary |
Also, it would make sense to have a ufunc loop for |
Yes, and each of those calls the relevant divmod function defined in |
It should be pretty straightforward to add loops for both of these, right? On the note of adding loops - it seems that we have two different methods of defining inner loops - one with a scalar function and an existing loop that calls it through the data pointer, and one that uses macros to instantiate a full loop containing that operation. Which one is preferable? is my approach in #8774 (gcd) the right one? Or was the approach in #8820 (heaviside) better? |
See #8967 for a ufunc for Nobody really uses |
I'd wager that more people use |
Bit late to the game, but we do have |
@mhvk if you're up for turning
If someone is using |
I actually might give |
@shoyer - that would be great! |
See #9063 |
These are not terribly useful, but would be nice to have for completeness, so we can implement every binary operation between arrays by calling
__array_ufunc__
(e.g., forNDArrayOperatorsMixin
, charris#19).Currently ndarray implements
__divmod__
and__pos__
in terms of other helper functions that aren't exposed in the API:numpy/numpy/core/src/multiarray/number.c
Line 1120 in f368286
The text was updated successfully, but these errors were encountered: