[SciPy-user] sparse.lil_matrix accepts array assignments to elements
Andrew Hawryluk
HAWRYLA at novachem.com
Fri Mar 20 12:33:38 EDT 2009
Hi, we noticed an unexpected behaviour in sparse.lil_matrix today. The
following runs without errors:
import numpy as np
from scipy import sparse
a = sparse.lil_matrix((10,10))
a[0,0] = np.array([3.1415926,3.1415926])
I would have expected some error ('angry red text' in IDLE) when I tried
to assign a 1D array to a single element of the sparse array, but no
error occurs. (This assignment was a bug in our code.) We found the
error later when we tried a.tocsr().
Should there be a type-check of some sort in sparse.lil_matrix to
prevent this?
Andrew
More information about the SciPy-User
mailing list