Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TaggingBackends
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nyx
TaggingBackends
Commits
42d7a3b4
Commit
42d7a3b4
authored
2 years ago
by
François LAURENT
Browse files
Options
Downloads
Patches
Plain Diff
fixes #23
parent
ad219f83
No related branches found
No related tags found
No related merge requests found
Pipeline
#101685
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
src/taggingbackends/data/trxmat.py
+20
-4
20 additions, 4 deletions
src/taggingbackends/data/trxmat.py
with
21 additions
and
5 deletions
pyproject.toml
+
1
−
1
View file @
42d7a3b4
...
@@ -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"
...
...
This diff is collapsed.
Click to expand it.
src/taggingbackends/data/trxmat.py
+
20
−
4
View file @
42d7a3b4
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment