[SciPy-Dev] scipy.io.savemat and sparse matrices
Matthew Brett
matthew.brett at gmail.com
Fri Apr 8 14:05:50 EDT 2011
Hi,
On Fri, Apr 8, 2011 at 5:17 AM, Nils Wagner
<nwagner at iam.uni-stuttgart.de> wrote:
> Hi all,
>
> I tried to save a sparse matrix
>
>
> savemat('mass.mat',dict(M_sparse))
> File
> "/data/home/nwagner/local/lib/python2.5/site-packages/scipy/sparse/base.py",
> line 109, in __iter__
> yield self[r,:]
> TypeError: 'coo_matrix' object is unsubscriptable
I think you'll get the same error from:
dict(M_sparse)
that is - you need to give the input dict a key, with the sparse
matrix as a value, as in
savemat('mass.mat', dict(aname=M_sparse))
Best,
Matthew
More information about the SciPy-Dev
mailing list