Hi Ariel,

I just fixed this issue in the latest commit. It turns out that each
dataset also has an "attribute" field where all the metadata are stored. I
am using this information to check whether an array is a Matlab string. Now
I'm moving on to refactor the magic with ZMQ.

Sorry for the delay. I'm trapped in one class project this weekend.

Best,
Haoxing


2014-01-31 Ariel Rokem <notifications@github.com>:

> In pymatbridge/matlab_magic.py:
>
> > +            # Currently only supports numerical array
> > +            data = f[var_name].value
> > +            if len(data.dtype) > 0:
> > +                # must be complex data
> > +                data = data['real'] + 1j * data['imag']
> > +            return np.squeeze(data.T)
> > +
> > +        elif isinstance(f[var_name], h5py.Group):
> > +            data = {}
> > +            for mem_name in f[var_name].iterkeys():
> > +                if isinstance(f[var_name][mem_name], h5py.Dataset):
> > +                    data[mem_name] = f[var_name][mem_name].value
> > +                    data[mem_name] = np.squeeze(data[mem_name].T)
> > +                    # This is a quick hack. Need to find a better way
> > +                    # to identify string
> > +                    if data[mem_name].dtype == 'uint16':
>
> Do you know if pytables knows how to handle this? That's what we had
> before h5py, and we changed that recently. Could you please take a look?
> ... <#143ea6297261f36a_>
> On Fri, Jan 31, 2014 at 2:16 PM, Haoxing Zhang <notifications@github.com>wrote:
> In pymatbridge/matlab_magic.py: > + # Currently only supports numerical
> array > + data = f[var_name].value > + if len(data.dtype) > 0: > + # must
> be complex data > + data = data['real'] + 1j * data['imag'] > + return
> np.squeeze(data.T) > + > + elif isinstance(f[var_name], h5py.Group): > +
> data = {} > + for mem_name in f[var_name].iterkeys(): > + if
> isinstance(f[var_name][mem_name], h5py.Dataset): > + data[mem_name] =
> f[var_name][mem_name].value > + data[mem_name] =
> np.squeeze(data[mem_name].T) > + # This is a quick hack. Need to find a
> better way > + # to identify string > + if data[mem_name].dtype ==
> 'uint16': Yes I'm afraid so. I still cannot find how Matlab identifies a
> character array. 2014-01-31 Ariel Rokem <notifications@github.com>: ...
> <#143ea5fdc617002b_> In pymatbridge/matlab_magic.py: > + # Currently only
> supports numerical array > + data = f[var_name].value > + if
> len(data.dtype) > 0: > + # must be complex data > + data = data['real'] +
> 1j * data['imag'] > + return np.squeeze(data.T) > + > + elif
> isinstance(f[var_name], h5py.Group): > + data = {} > + for mem_name in
> f[var_name].iterkeys(): > + if isinstance(f[var_name][mem_name],
> h5py.Dataset): > + data[mem_name] = f[var_name][mem_name].value > +
> data[mem_name] = np.squeeze(data[mem_name].T) > + # This is a quick hack.
> Need to find a better way > + # to identify string > + if
> data[mem_name].dtype == 'uint16': Would this mean that we can't pass int16
> data? That's not great. -- Reply to this email directly or view it on
> GitHub<
> https://github.com/arokem/python-matlab-bridge/pull/43/files#r9357261> .
> -- Reply to this email directly or view it on GitHub<
> https://github.com/arokem/python-matlab-bridge/pull/43/files#r9359651> .
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/arokem/python-matlab-bridge/pull/43/files#r9359740>
> .
>