[SciPy-user] Matlab IO -- can others with matlab test this bug?

Zachary Pincus zachary.pincus@yale....
Mon Jul 28 23:04:09 CDT 2008


Hi Johnny,

> Which version of SciPy are you using? I have 0.6.0 and MATLAB
> 7.6.0.324 (R2008a).

Foolish me for not specifying! I'm using a recent-ish SVN checkout of  
scipy: 0.7.0.dev4393.

It seems that the version-5 format writing came into the svn early  
this year, after the 0.6 release. The version-4 mat-file IO code seems  
to deal fine with short names.

Thanks again,

Zach


>
>
>>> import scipy.io
>>> scipy.io.savemat('works.mat', {'abcde':1}) # My version of SciPy  
>>> doesn't support a format argument
>>> scipy.io.savemat('fails.mat', {'abcd':1})
>
> works fine.
>
> Hope this helps.
> Jonny
>
> On Tue, Jul 29, 2008 at 1:04 PM, Zachary Pincus <zachary.pincus@yale.edu 
> > wrote:
>> Hi,
>>
>> I have found that scipy's .mat-file IO creates version-5 files that
>> cannot be read by the version of matlab I have access to, if a
>> variable with less than five letters in the name is saved to that  
>> file.
>>
>> The version of matlab I have is 6.5.0.180913a (R13). Here's an  
>> example
>> to show the issue:
>>
>> python:
>>>>> import scipy.io
>>>>> scipy.io.savemat('works.mat', {'abcde':1}, format='5')
>>>>> scipy.io.savemat('fails.mat', {'abcd':1}, format='5')
>>
>> matlab:
>>>> load works
>>>> load fails
>> ??? Error using ==> load
>> Can't read file.
>>
>> Could others please test this code out with the version(s) of Matlab
>> that they have access to?
>>
>> The issue is that it appears that (at least my version of) matlab
>> assumes that for variables with <= 4-byte names, the "compressed data
>> element" format will be used in the file. Scipy.io.savemat does not  
>> do
>> this... However, the mat-file specification clearly states that this
>> format is *optional*, and so the scipy routines are technically
>> correct -- this is a matlab bug.
>>
>> If this bug with matlab's file IO is widespread, I will make a patch
>> for scipy so that short elements are written in the compressed  
>> format;
>> otherwise I'll just work around the issue by ensuring that I never  
>> use
>> any short names.
>>
>> I would be very grateful if others would test this.
>>
>> Zach
>>
>> _______________________________________________
>> SciPy-user mailing list
>> SciPy-user@scipy.org
>> http://projects.scipy.org/mailman/listinfo/scipy-user
>>
>
>
>
> -- 
> Jonathan J Hunt <jjh@42quarks.com>
> Homepage: http://www.42quarks.net.nz/wiki/JJH
> (Further contact details there)
> "Physics isn't the most important thing. Love is." Richard Feynman
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user



More information about the SciPy-user mailing list