savemat not working in SciPy 0.4.6?
Hello all I'm trying to use the savemat function in SciPy 0.4.6. The following code doesn't work: from numpy import array from scipy.io import savemat savemat('foo.mat', {'x' : array([0])}) The traceback: Traceback (most recent call last): File "frags.py", line 3, in ? savemat('foo.mat', {'x' : array([0])}) File "C:\Python24\Lib\site-packages\scipy\io\mio.py", line 875, in savemat fid.fwrite(variable+'\x00','char') File "C:\Python24\Lib\site-packages\scipy\io\mio.py", line 223, in write numpyio.fwrite(self,count,data,mtype,bs) numpyio.error: Does not support extended types. Is anybody else experiencing this problem? Regards Albert
Albert Strasheim wrote:
Hello all
I'm trying to use the savemat function in SciPy 0.4.6.
The following code doesn't work:
from numpy import array from scipy.io import savemat savemat('foo.mat', {'x' : array([0])})
The traceback:
Traceback (most recent call last): File "frags.py", line 3, in ? savemat('foo.mat', {'x' : array([0])}) File "C:\Python24\Lib\site-packages\scipy\io\mio.py", line 875, in savemat fid.fwrite(variable+'\x00','char') File "C:\Python24\Lib\site-packages\scipy\io\mio.py", line 223, in write numpyio.fwrite(self,count,data,mtype,bs) numpyio.error: Does not support extended types.
Is anybody else experiencing this problem?
This was a bug. This is updated in SVN. Here's a work-around. Replace data = asarray(data) the write method of fopen class with if isinstance(data, str): N, buf = len(data), buffer(data) data = ndarray(shape=(N,),dtype='B',buffer=buf) else: data = asarray(data) This is near line 218 of scipy/io/mio.py -Travis
participants (2)
-
Albert Strasheim -
Travis Oliphant