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

fixes #23

parent ad219f83
Branches
Tags
No related merge requests found
Pipeline #101685 passed
......@@ -7,7 +7,7 @@ authors = ["François Laurent"]
[tool.poetry.dependencies]
python = "^3.8"
julia = "^0.5.7"
hdf5storage = "^0.1.18"
hdf5storage = ">0.1.18"
h5py = "^3.1.0"
numpy = "^1.19.3"
......
......@@ -79,9 +79,25 @@ class TrxMat:
records = records.split()
if not lowlevel:
records, memoized_records = self._parse_record_names(records)
trx = hdf5storage.loadmat(self.path,
variable_names=["trx/"+record for record in records])
file = h5py.File(self.path, 'r')
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:
# TODO: replace hdf5storage or deprecate this use case
trx = hdf5storage.loadmat(self.path)
else:
# explicit record names required for memoization
......@@ -90,7 +106,7 @@ class TrxMat:
for varname in trx:
record = varname[4:]
vardata = trx[varname]
assert len(vardata) == 1
if numpy.isscalar(vardata): # hdf5storage
vardata = vardata[0]
try:
hook = getattr(self, record+"_hook")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment