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

Nils Wagner nwagner at mecha.uni-stuttgart.de
Tue Mar 7 03:28:36 CST 2006


Traceback (most recent call last):
  File "aispd.py", line 33, in ?
    M[:,j] = m_j
  File "/usr/lib64/python2.4/site-packages/scipy/sparse/sparse.py", line 
1308, in __setitem__
    self.indptr = resize1d(self.indptr, row+2)
TypeError: unsupported operand type(s) for +: 'slice' and 'int'
 >>> M
<420x420 sparse matrix of type '<type 'float64scalar'>'
        with 0 stored elements (space for 100)
        in Compressed Sparse Row format>
 >>> m_j
<420x1 sparse matrix of type '<type 'float64scalar'>'
        with 10 stored elements (space for 1002)
        in Compressed Sparse Row format>

How can I resolve this problem ?

 

for i in arange(0,420):
     M[i,j] = m_j[i]

seems to be not very efficient.

Nils



More information about the SciPy-user mailing list