[SciPy-user] loadmat: TypeError Array can not be safely cast to required type

Travis Oliphant oliphant at ee.byu.edu
Tue Apr 5 23:32:46 CDT 2005


Simon Burton wrote:

>Hi,
>
>I am having the same problem as mentioned here:
>http://www.scipy.net/pipermail/scipy-user/2004-December/003910.html
>
>Attached is a small example V6 .mat file that demonstrates the problem (scipy 0.3.2).
>A collegue says it works on his (older) scipy. I couldn't find where
>to download the old versions of scipy.
>
>thanks,
>
>Simon.
>
>Python 2.3.3 (#1, Dec 16 2004, 12:18:55)
>[GCC 3.3.3 (Debian)] on linux2
>Type "help", "copyright", "credits" or "license" for more information.
>  
>
>>>>import scipy.io.mio as sp
>>>>sp.loadmat('x') # version 4 files work OK
>>>>        
>>>>
>{'x': array([ 1.])}
>  
>
>>>>sp.loadmat('x') # version 6 file
>>>>        
>>>>
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>  File "/home/groups/SML/lib/python2.3/site-packages/scipy/io/mio.py", line 692, in loadmat
>    thisdict = _loadv5(fid,basename)
>  File "/home/groups/SML/lib/python2.3/site-packages/scipy/io/mio.py", line 631, in _loadv5
>    el, varname = _get_element(fid)
>  File "/home/groups/SML/lib/python2.3/site-packages/scipy/io/mio.py", line 619, in _get_element
>    el, name = _parse_mimatrix(fid,numbytes)
>  File "/home/groups/SML/lib/python2.3/site-packages/scipy/io/mio.py", line 510, in _parse_mimatrix
>    result = squeeze(transpose(reshape(result,dims[::-1])))
>TypeError: Array can not be safely cast to required
>  
>

I think this is a problem with the Numeric version you are using.  There 
were some 64-bit "fixes" that broke a few things that were later fixed. 
   Try installing a later version of Numeric.

-Travis



More information about the SciPy-user mailing list