[SciPy-dev] Error in savemat

Larsson Omberg lom at larssono.com
Sun Feb 27 21:47:30 EST 2005


Hi:

I have been using savemat in mio.py to save numerical arrays but ran
into problem of saving text arrays.  The issue seems to be that the 'c'
typecode is not included in the storage dictionary.  According to the
level 4 mat file format it should be represented by a P=5.  I have
included a diff of the edited file.  I also include a sample python
script that crashes the original code.

Could this be included in the scipy code?

/larsson


*** mio.py      2005-02-27 20:17:38.000000000 -0600
--- /SciPy_complete-0.3.2/build/lib.linux-i686-2.3/scipy/io/mio.py      
2003-12-13 07:44:50.000000000 -0600
***************
*** 787,793 ****
      This saves the arrayobjects in the given dictionary to a matlab
Version 4
      style .mat file.
      """
!     storage = {'D':0,'d':0,'F':1,'f':1,'l':2,'i':2,'s':3,'b':5,'c':5,}
      if filename[-4:] != ".mat":
          filename = filename + ".mat"
      fid = fopen(filename,'wb')
--- 787,793 ----
      This saves the arrayobjects in the given dictionary to a matlab
Version 4
      style .mat file.
      """
!     storage = {'D':0,'d':0,'F':1,'f':1,'l':2,'i':2,'s':3,'b':5}
      if filename[-4:] != ".mat":
          filename = filename + ".mat"
      fid = fopen(filename,'wb')




from scipy import *
from scipy.io import savemat

dict={}
dict['names'] = array(['hello', 'there', 'ha'])
savemat('test', dict)




More information about the SciPy-Dev mailing list