Skip to content
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

Sparse/dense matrix inplace operations fail due to __numpy_ufunc__ #2938

Closed
pv opened this issue Sep 27, 2013 · 1 comment · Fixed by #2940
Closed

Sparse/dense matrix inplace operations fail due to __numpy_ufunc__ #2938

pv opened this issue Sep 27, 2013 · 1 comment · Fixed by #2940
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.sparse
Milestone

Comments

@pv
Copy link
Member

pv commented Sep 27, 2013

With current Scipy master + Numpy master, the following fails:

>>> x = np.ones(4)
>>> y = scipy.sparse.csr_matrix(x)
>>> x += y
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __numpy_ufunc__ not implemented for this type.

This used to work via csr_matrix.__radd__, but the current behavior in Numpy master is to pass through the exception rather than return NotImplemented, so that __radd__ is never called.

Two places to fix:

(i) The scipy.spmatrix should support the out array argument
(ii) Numpy should be fixed so that __radd__ gets called even if the __numpy_ufunc__ mechanism ends up with the conclusion that the operation is not supported.

@pv
Copy link
Member Author

pv commented Oct 11, 2013

Fixed in gh-2940

@pv pv closed this as completed Oct 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.sparse
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant