-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: Make ndarray inplace operators forward calls when needed. #9021
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
Conversation
Needs documentation changes too - this broken behaviour was explicitly documented |
So I think the conclusion of that discussion was specifically that if the RHS object sets If I'm reading right, I think that the |
@eric-wieser Yeah, documentation still needs fixes. No new tests are needed after the small fix in this PR. Probably should add a note there. |
@njsmith Sounds like we need an |
Thinking about it, we should probably raise a deprecation warning. Sparse (and others), really should not expect it to work with ndarrays because Python does the wrong thing there. |
2357509
to
c612792
Compare
OK, fixed up so that in-place ops forward on I'm going to wait on documentation until #9014 goes in so as to avoid conficts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continuous integration to the rescue! But all looks OK to me (modulo a space).
numpy/core/src/multiarray/number.c
Outdated
return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.add); | ||
} | ||
|
||
static PyObject * | ||
array_inplace_subtract(PyArrayObject *m1, PyObject *m2) | ||
{ | ||
INPLACE_GIVE_UP_IF_NEEDED( | ||
m1, m2, nb_inplace_subtract,array_inplace_subtract); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trivial fix: space after ,
For backward compatibility, we need to let `__array_priority__` determine the override for inplace ops. If `__array_ufunc__ = None` on the right hand side it is still the case that TypeError will be raised. This fixes SciPy test failures of the type ndarray += sparse_array Closes numpy#9019.
c612792
to
105557a
Compare
@mhvk Thanks for the quick review. |
For backward compatibility, we need to let
__array_priority__
determine the override for inplace ops. If
__array_ufunc__ = None
on the right hand side it is still the case that TypeError will be
raised.
This fixes SciPy test failures of the type
Closes #9019.