problem loading matlab data with ompc and python

no1 no1.woot at gmail.com
Thu May 24 15:47:18 EDT 2012


On Thursday, May 24, 2012 5:06:41 AM UTC-7, Tim Williams wrote:
> On May 23, 5:10 pm, no1 <no1.w... at gmail.com> wrote:
> > Hi, we're investigating transitioning our company from matlab to python. We found OMPC as a MATLAB m-file-to Python translator, but we're encountering a problem using the translated code to import MATLAB data structures into Python. For example, when we save data within MATLAB this way:
> >
> > x.a = 5;
> > x.b = 6;
> > save -v6 test x
> >
> > this saves data in test.mat, with MATLAB version 6 compatibility (OMPC says it's not compatible with the latest versions of MATLAB). The code to read in data in MATLAB is just
> >
> > load test
> >
> > and when we run it through OMPC we get
> >
> > load(mstring('test.mat'))
> >
> > but when we run it we get the error message
> >
> > File "ompclib\ompclib_numpy.py", line 1496, in load
> > KeyError: "[('a', '|O4'), ('b', '|O4')]"
> >
> > Reading in simpler data (up to arrays) does not have this problem.
> >
> > To get other people in the company to transition, we were hoping that the translation process could be done in one step or on the fly. We could read in MATLAB data using I/O functions imported from scipy, but then the transition isn't seamless any more.
> >
> > Is there a simple fix to using OMPC? Or a similar alternative that would work better?
> >
> > Thanks
> 
> Have you tried using loadmat from the scipy.io module?
> 
> http://docs.scipy.org/doc/scipy/reference/io.html

Yes (I mentioned the scipi I/O module near the end of my original post) but we were hoping not to have to require the users to learn any Python to start. The simpler the process, the less resistance to using the "new" Python methodology; we were hoping the use of a single "black box" like translator (OMPC) would be enough. We'd really like to avoid any additional steps for the user, like rewriting code, otherwise the users are going to resist the transition.



More information about the Python-list mailing list