[SciPy-user] Re: io.loadmat: broken?

Travis Oliphant oliphant at ee.byu.edu
Tue Jan 11 18:35:48 EST 2005


Yichun Wei wrote:

> Here is the file (I should have said that it is a .mat file saved 
> using -v6 option of Matlab 7):
>
> >> a = 1; save -v6 a.mat a
> >> clear
> >> load a.mat
> >> a
> a =
>      1
>
> The Enthought python with Scipy 0.3 loads this .mat file fine, 
> however, it is not the case with Scipy 0.3.2:
>
> >>> a = io.loadmat('a')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "C:\Python23\Lib\site-packages\scipy\io\mio.py", line 692, in 
> loadmat
>     thisdict = _loadv5(fid,basename)
>   File "C:\Python23\Lib\site-packages\scipy\io\mio.py", line 631, in 
> _loadv5
>     el, varname = _get_element(fid)
>   File "C:\Python23\Lib\site-packages\scipy\io\mio.py", line 619, in 
> _get_elemen
> t
>     el, name = _parse_mimatrix(fid,numbytes)
>   File "C:\Python23\Lib\site-packages\scipy\io\mio.py", line 510, in 
> _parse_mima
> trix
>     result = squeeze(transpose(reshape(result,dims[::-1])))
> TypeError: Array can not be safely cast to required type
>
>
> >>> import scipy
> >>> scipy.__version__
> '0.3.2_280.4176'
> >>>
> >>> import Numeric
> >>> Numeric.__version__
> '23.6'
>
> I am not sure if this is brought by the new Numeric used here. This is 
> on a Win2k. I am not sure if it is the case on other platforms.
>
> > Could you attach the test file so that I can debug the problem?
> >
> > Thanks,
>
> > -Travis
>
>
> Thanks for looking into this issue! I'm looking forward to use Scipy 
> 0.3.2 so as to be able to work with wxpython 2.5.x.x, pythoncard etc...


This is a problem with Numeric. 

Numeric 23.7 fixes the issue that is causing this problem.   I recommend 
installing Numeric 23.7.

In the mean time, you can temporarily fix the issue by replacing

dims[::-1] with tuple(dims[::-1])

in line 510 in io/mio.py 

Best,

-Travis




More information about the SciPy-User mailing list