[SciPy-User] loadmat, savemat and strings

Matthew Brett matthew.brett at gmail.com
Tue May 4 02:48:16 EDT 2010


Hi,

>> from scipy import io
>> a = np.array(['HelloWorld', 'Foobar'])
>> io.savemat('tmp.mat', dict(a=a))
>> res = io.loadmat('tmp.mat')
>> print res['a']
>> ->
>> array([u'HloolWw', u'elWrdo'],
>>       dtype='<U10')
>
>> io.savemat('tmp.mat', dict(a=a.astype('U')))
>> res = io.loadmat('tmp.mat')
>
>> TypeError: buffer is too small for requested array
>> Is this a bug (I guess it shouldn't throw errors quite like this in any
>> case), and is there a successful method for saving string types into matlab
>> files and retrieving them?
>
> Certainly a bug - I'll have a look later today, thanks for the report,

The two bugs you found should be fixed in latest SVN...

Best,

Matthew



More information about the SciPy-User mailing list