[SciPy-user] 'obj2dtype' not found in 'mio.py'

Michael Sorich michael.sorich at gmail.com
Fri Feb 10 00:34:53 CST 2006


Hi,

In the course of trying to use scipy.io.loadmat to load a v4 matlab file, I
have run across this error. Does anyone know where obj2dtype is defined?
(Using an old version of scipy version (3.x) this matlab file could be
loaded.)

>> import scipy.io
>>> scipy.io.loadmat('D:\\test.mat')
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "D:\Python24\Lib\site-packages\scipy\io\mio.py", line 803, in loadmat
    varname = fid.fread(header[-1],'char')[:-1]
  File "D:\Python24\Lib\site-packages\scipy\io\mio.py", line 249, in read
    howmany,stype = getsize_type(stype)
  File "D:\Python24\Lib\site-packages\scipy\io\mio.py", line 48, in
getsize_type
    mtype = obj2dtype(mtype)
NameError: global name 'obj2dtype' is not defined
>>> scipy.__version__
'0.4.4'
>>> import numpy
>>> numpy.__version__
'0.9.4'
>>>

numpy-0.9.4.win32-py2.4.exe and scipy-0.4.4.win32-py2.4-P4SSE2.exe were used
to install the code on windows XP with Python 2.4.2.

On a less important note it seems that scipy.io.loadmat does not accept file
names separated with '/' on windows

>>> scipy.io.loadmat('D:/test.mat')
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "D:\Python24\Lib\site-packages\scipy\io\mio.py", line 740, in loadmat
    raise IOError, "%s not found on the path." % name
IOError: test not found on the path.
>>>

The line 'if os.sep in name:' is evaluated as false as os.sep is ''\\' on
windows and thus the code assumes that the file name is not a full path
name. However, the os.path module recognises '/' as a path separator. Eg
>>> import os.path
>>> os.path.isabs('D:/test.mat')
True
>>> os.path.split('D:/test.mat')
('D:/', 'test.mat')
>>>

If it considered OK to use '\' as a path separator on windows perhaps this
line can be changed to 'if os.path.isabs(name):' or maybe 'if
os.path.split('D/test.mat')[0]
!= "":'

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.scipy.net/pipermail/scipy-user/attachments/20060210/4dd38e92/attachment.htm


More information about the SciPy-user mailing list