[NumPy-Tickets] [NumPy] #2058: Strange behavior of binary ufunc with scipy sparse matrices

NumPy Trac numpy-tickets@scipy....
Fri Feb 17 05:39:00 CST 2012


#2058: Strange behavior of binary ufunc with scipy sparse matrices
------------------------+---------------------------------------------------
 Reporter:  pv          |       Owner:  somebody   
     Type:  defect      |      Status:  new        
 Priority:  normal      |   Milestone:  Unscheduled
Component:  numpy.core  |     Version:  1.6.1      
 Keywords:              |  
------------------------+---------------------------------------------------
 The ufuncs behave strangely when fed Scipy sparse matrices:
 {{{
 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
 }}}

 There are a couple things amiss here, the reason for which probably
 resides in Numpy:

 - returning NotImplemented instead of raising ValueError (same as #1494 )

 - it seems that in the last case, `csc_matrix.multiply` is not called.

 See also: http://projects.scipy.org/scipy/ticket/1598

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/2058>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list