[SciPy-dev] [patch] read/write v5 .mat files with structs, cell arrays, objects, or function handles

Zachary Pincus zachary.pincus at yale.edu
Wed Oct 1 14:52:32 EDT 2008


Hi Ray,

Those changes look really useful!

Stéfan van der Walt <stefan at sun.ac.za> (on this email list) and  
Matthew Brett <matthew.brett at gmail.com> (not on the list?) seem to be  
coordinating the matlab IO (at least, they were the ones who  
shepherded my recent patch to the same).

I'm not 100% sure what the backwards-compatibility guarantees for  
scipy are right now, but the matlab 5 IO is pretty new, so hopefully  
useful changes like these won't be a problem. (Any one can say for  
sure?)

One comment -- perhaps for objects, would a 0-d "array scalar" (i.e.  
shape=()) struct be better than a 1x1 struct? I'm not really sure  
either way...

Anyhow, thanks for the patch. This should be very helpful.

Best,
Zach


On Oct 1, 2008, at 11:52 AM, Thouis (Ray) Jones wrote:

> I just submitted a patch (http://scipy.org/scipy/scipy/ticket/743)
> extending the functionality of io.matlab for v5 files, adding writers
> for structs, cell arrays, & objects, and readers+writers for function
> handles and 64-bit ints.
>
> The patch modifies the numpy types of strings, structs, and objects
> loaded from matlab:
> matlab strings are loaded as numpy arrays of unicode strings, rather
> than numpy arrays of objects.
> structs are loaded as numpy arrays with dtype [(field_name,  
> object), ...]
> matlab objects are wrapped in an mio5.MatlabObject  instance, which
> contains a 1x1 struct & the object classname.
> (function handles are also wrapped in a special object in mio5.py)
>
> These changes were to make the scipy<->matlab mapping more explicit.
> The changes to the string type probably don't break any existing code.
> The changes to the struct & matlab objects probably do.  It's
> possible to make both of these backward compatible, if that's a
> priority.  We're looking for feedback on that (or any other) issue.
>
> Ray Jones
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev




More information about the SciPy-Dev mailing list