[SciPy-user] unsupported operand type(s) for +: 'slice' and 'int'

Ed Schofield schofield at ftw.at
Tue Mar 7 08:24:20 CST 2006


Nils Wagner wrote:
> I followed your advice.
> M = dok_matrix((n,n))
>
> Traceback (most recent call last):
>   File "aispd.py", line 40, in ?
>     M[:,j] = m_j
>   File "/usr/lib64/python2.4/site-packages/scipy/sparse/sparse.py", line 
> 1644, in __setitem__
>     if len(seq) != len(value):
> TypeError: __len__() should return an int
>  >>> M
> <420x420 sparse matrix with 0 stored elements in Dictionary Of Keys format>
>  >>> m_j
> <420x1 sparse matrix of type '<type 'float64scalar'>'
>         with 3 stored elements (space for 2002)
>         in Compressed Sparse Row format>
>
> Am I missing something ?
>   
Yes, m_j needs to be a dok_matrix too.


-- Ed



More information about the SciPy-user mailing list