[SciPy-dev] Possibly bug in sparse.py

Nils Wagner nwagner at mecha.uni-stuttgart.de
Tue Feb 14 06:59:49 EST 2006


Robert Cimrman wrote:
>Nils Wagner wrote:
>  
>>    C =dot(A,XX)+dot(XX,B)
>>  File "/usr/local/lib/python2.4/site-packages/scipy/sparse/sparse.py",
>>line 532, in __add__
>>    raise ValueError, "inconsistent shapes"
>>ValueError: inconsistent shapes
>>
>>    
>>>>>A
>>>>>          
>><317x317 sparse matrix of type '<type 'float64scalar'>'
>>        with 7327 stored elements (space for 7327)
>>        in COOrdinate format>
>>
>>    
>>>>>XX
>>>>>          
>>array([[0, 1, 1, ..., 1, 1, 1],
>>       [1, 0, 1, ..., 1, 1, 1],
>>       [1, 1, 0, ..., 1, 1, 1],
>>       ...,
>>       [1, 1, 1, ..., 1, 1, 1],
>>       [1, 1, 1, ..., 1, 1, 1],
>>       [1, 1, 1, ..., 1, 1, 1]])
>>
>>    
>>>>>shape(XX)
>>>>>          
>>(317, 10)
>>
>>    
>>>>>shape(B)
>>>>>          
>>(10, 10)
>>
>>
>>    
>>>>>B
>>>>>          
>><10x10 sparse matrix of type '<type 'float64scalar'>'
>>        with 28 stored elements (space for 28)
>>        in Compressed Sparse Column format>
>> 
>>How can I fix this problem ?
>>    
>
>First, use A * XX + XX * B instead of dot, since dot is a numpy.core 
>function and as such cannot handle sparse matrices.
>
>Then there was a bug in the coo_matrix() constructor (not fixed yet in 
>svn, cannot log in...) causing that the shape was one less than the 
>actual shape... Thanks for debugging!
>
>---
>Side note, not directly related to your problem:
>
>Another bug in the coo_matrix() constructor is that it does not work for 
>all value types (e.g. int32), because some dtypes are probably missing 
>in the type translation table of sparse.py - can someone (Travis? :) 
>help with this? I have followed the recent changes to the dtype object 
>only superficially...
>
>r.
>
>_______________________________________________
>Scipy-dev mailing list
>Scipy-dev at scipy.net
>http://www.scipy.net/mailman/listinfo/scipy-dev
>  

Hi Robert,

Thank you for your comments.
Meanwhile I ask you to reply to some questions raised up w.r.t. to
sparse matrix objects.
See FAQ_sparse.py for details.

I look forward to hearing from you.

Cheers
                   Nils

 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: FAQ_sparse.py
Type: text/x-python
Size: 421 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20060214/29eb537e/attachment.py>


More information about the SciPy-Dev mailing list