Skip to content
Snippets Groups Projects
Commit 42d7a3b4 authored by François  LAURENT's avatar François LAURENT
Browse files

fixes #23

parent ad219f83
No related branches found
No related tags found
No related merge requests found
Pipeline #101685 passed
...@@ -7,7 +7,7 @@ authors = ["François Laurent"] ...@@ -7,7 +7,7 @@ authors = ["François Laurent"]
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.8" python = "^3.8"
julia = "^0.5.7" julia = "^0.5.7"
hdf5storage = "^0.1.18" hdf5storage = ">0.1.18"
h5py = "^3.1.0" h5py = "^3.1.0"
numpy = "^1.19.3" numpy = "^1.19.3"
......
...@@ -79,9 +79,25 @@ class TrxMat: ...@@ -79,9 +79,25 @@ class TrxMat:
records = records.split() records = records.split()
if not lowlevel: if not lowlevel:
records, memoized_records = self._parse_record_names(records) records, memoized_records = self._parse_record_names(records)
trx = hdf5storage.loadmat(self.path, file = h5py.File(self.path, 'r')
variable_names=["trx/"+record for record in records]) try:
trx = {}
for record in records:
varname = 'trx/'+record
refs = file[varname][0,:]
# np arrays (and transpose) for backward compatibility
trx[varname] = numpy.empty(refs.shape, dtype=object)
if record == 'id':
for i, ref in enumerate(refs):
trx[varname][i] = numpy.array([file[ref][:].tobytes().decode('utf-16')])
else:
for i, ref in enumerate(refs):
trx[varname][i] = numpy.transpose(file[ref][:])
assert not numpy.isscalar(trx[varname])
finally:
file.close()
elif lowlevel: elif lowlevel:
# TODO: replace hdf5storage or deprecate this use case
trx = hdf5storage.loadmat(self.path) trx = hdf5storage.loadmat(self.path)
else: else:
# explicit record names required for memoization # explicit record names required for memoization
...@@ -90,8 +106,8 @@ class TrxMat: ...@@ -90,8 +106,8 @@ class TrxMat:
for varname in trx: for varname in trx:
record = varname[4:] record = varname[4:]
vardata = trx[varname] vardata = trx[varname]
assert len(vardata) == 1 if numpy.isscalar(vardata): # hdf5storage
vardata = vardata[0] vardata = vardata[0]
try: try:
hook = getattr(self, record+"_hook") hook = getattr(self, record+"_hook")
except AttributeError: except AttributeError:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment