Skip to content

Commit

Permalink
fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
skjerns committed Aug 8, 2020
1 parent c2428c0 commit d2be160
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions mat73/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
import numpy as np
import h5py

class AttrDict(dict):
"""
We use AttributeDicts to simulate structs.
this way we simulate the accessing via 'struct.variable.subvariable'
"""
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self


class HDF5Decoder():
Expand Down Expand Up @@ -55,7 +47,7 @@ def unpack_mat(self, hdf5, depth=0):
"""
if depth==99:raise Exception
if isinstance(hdf5, (h5py._hl.group.Group)):
d = AttrDict()
d = dict()
for key in hdf5:
elem = hdf5[key]
self.d[key] = hdf5
Expand Down Expand Up @@ -101,7 +93,10 @@ def convert_mat(self, dataset):
if len(cell)==1:cell = cell[0]
return cell
elif mtype=='char':
return ''.join([chr(x) for x in dataset]).replace('\x00', '')
string_array = np.array(dataset).ravel()
string_array = ''.join([chr(x) for x in string_array])
string_array = string_array.replace('\x00', '')
return string_array
elif mtype=='bool':
return bool(dataset)
elif mtype=='logical':
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setuptools.setup(
name='mat73',
version='0.40',
version='0.41',
author="skjerns",
author_email="[email protected]",
description="Load MATLAB .mat 7.3 into Python native data types",
Expand Down

0 comments on commit d2be160

Please sign in to comment.