[SciPy-user] Sparse matrices support and io.loadmat

Nils Wagner nwagner at mecha.uni-stuttgart.de
Tue Oct 19 06:36:15 CDT 2004


Hi all,

Sparse matrices stored with  Matlab's save command (option -v4)
are not supported  by io.loadmat . 

 
>>> io.loadmat('speyev4.mat')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/site-packages/scipy/io/mio.py",
line 744, in loadmat
    raise ValueError, "Cannot handle sparse matrices, yet."
ValueError: Cannot handle sparse matrices, yet.

Sparse matrices which are saved without the option -v4 in MATLAB
cannot be loaded in scipy.
 
>>> io.loadmat('speyev5.mat')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/site-packages/scipy/io/mio.py",
line 692, in loadmat
    thisdict = _loadv5(fid,basename)
  File "/usr/lib/python2.3/site-packages/scipy/io/mio.py",
line 631, in _loadv5
    el, varname = _get_element(fid)
  File "/usr/lib/python2.3/site-packages/scipy/io/mio.py",
line 619, in _get_element
    el, name = _parse_mimatrix(fid,numbytes)
  File "/usr/lib/python2.3/site-packages/scipy/io/mio.py",
line 568, in _parse_mimatrix
    spmat =
scipy.sparse.spmatrix(dims[1],dims[0],typecode=res.typecode())
TypeError: __init__() got an unexpected keyword argument
'typecode'

Nils


-------------- next part --------------
A non-text attachment was scrubbed...
Name: speyev4.mat
Type: application/octet-stream
Size: 166 bytes
Desc: not available
Url : http://www.scipy.net/pipermail/scipy-user/attachments/20041019/ea2cdb50/speyev4.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: speyev5.mat
Type: application/octet-stream
Size: 288 bytes
Desc: not available
Url : http://www.scipy.net/pipermail/scipy-user/attachments/20041019/ea2cdb50/speyev5.obj


More information about the SciPy-user mailing list