Bad behavior of sparse matrices in a binary ufunc (Trac #1598) #2123

Closed
scipy-gitbot opened this Issue Apr 25, 2013 · 1 comment

2 participants

@scipy-gitbot

Original ticket http://projects.scipy.org/scipy/ticket/1598 on 2012-02-17 by @pv, assigned to @wnbell.

This behavior should be improved:

import numpy as np
import scipy.sparse as sp
A = sp.csc_matrix(np.identity(5))
B = np.asmatrix(np.ones((5,5)))
print np.multiply(A,A)
# <5x5 sparse matrix of type '<class 'numpy.float64'>'
#   with 5 stored elements in Compressed Sparse Column format>
print np.multiply(B,A)
# NotImplemented
print np.multiply(A,B).dtype
# object

I don't actually follow what happens in the last one --- according to pdb, the execution never reaches csc_matrix.multiply. Instead, one gets calls to csc_matrix.__mul__.

Also, these routines should never return NotImplemented.

@pv
SciPy member
pv commented Sep 22, 2013

Fixed in gh-2869

@pv pv closed this Sep 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment