[SciPy-User] Using scipy.io.loadmat to read Matlab containers.Map object?

Gerrit Holl gerrit.holl at ltu.se
Tue May 15 04:17:37 EDT 2012


On 14 May 2012 20:36, Matthew Brett <matthew.brett at gmail.com> wrote:
> Hi,
>
> On Mon, May 14, 2012 at 7:51 AM, Gerrit Holl <gerrit.holl at ltu.se> wrote:
>> Hi,
>>
>> is it possible to use scipy.io.loadmat to read a Matlab containers.Map object?
>>
>>>> cm = containers.Map();
>>>> cm('abc') = 42;
>>>> save('/tmp/test.mat', 'cm');
>>
>>
>> In [15]: M = scipy.io.loadmat('/tmp/test.mat')
>>
>> In [16]: M.keys()
>> Out[16]: ['__function_workspace__', 'None', '__version__',
>> '__header__', '__globals__']
>>
>> In [17]: M["None"]
>> Out[17]:
>> MatlabOpaque([ ('cm', 'MCOS', 'containers.Map', [[3707764736L], [2L],
>> [1L], [1L], [1L], [1L]])],
>>      dtype=[('s0', '|O8'), ('s1', '|O8'), ('s2', '|O8'), ('arr', '|O8')])
>
> Just because I didn't know what a container.Map was, it looks like
> it's a MATLAB dict equivalent:
>
> http://www.mathworks.com/help/techdoc/matlab_prog/brqqo69.html
>
> I see that I or someone thought that types labeled as MatlabOpaque
> were MATLAB functions:
>
> https://github.com/scipy/scipy/blob/master/scipy/io/matlab/mio5_params.py#L51
>
> but at least, the internal structure looks rather confusing.  Do you
> recognize any of the structure in what got loaded?  Does it load OK
> when loaded in Octave?

I don't recognise anything, and nor does Octave.

containers.Map are a relatively new type in Matlab, not very well
known and quite underused. They're indeed very close to being a Python
dict, except that all keys must be of the same type and can only be
numeric or character arrays. But that means that Matlab->Python is a
well-defined translation.

It appears the answer to my question is "no". Is this something to
file an 'issue' for, I suppose it would be desirable to be able to
read those?

Gerrit.

-- 
Gerrit Holl
PhD student at Division of Space Technology, Luleå University of
Technology, Kiruna, Sweden
http://www.sat.ltu.se/members/gerrit/



More information about the SciPy-User mailing list