Skip to content

Commit da36b67

Browse files
committed
bugfix for complex data
1 parent 1d20faa commit da36b67

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pymatbridge/matlab_magic.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import numpy as np
2323
try:
24-
import tables
24+
import h5py
2525
import scipy.io as sio
2626
has_io = True
2727
except ImportError:
@@ -62,11 +62,15 @@ def __str__(self):
6262

6363
def loadmat(fname):
6464
"""
65-
Use pytables to read a variable from a v7.3 mat file
65+
Use h5py to read a variable from a v7.3 mat file
6666
"""
6767

68-
f = tables.File(fname)
69-
return f.root.__getattr__(f.root.__members__[0])
68+
f = h5py.File(fname)
69+
data = f.values()[0][:]
70+
if len(data.dtype) > 0:
71+
# must be complex data
72+
data = data['real'] + 1j * data['imag']
73+
return data
7074

7175

7276
def matlab_converter(matlab, key):

0 commit comments

Comments
 (0)