Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pytrxmat
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
pytrxmat
Commits
84088172
Commit
84088172
authored
8 months ago
by
Alexandre BLANC
Browse files
Options
Downloads
Patches
Plain Diff
Change trx syntax in repository, fix larva indexing
parent
850c0947
Branches
main
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/pytrxmat/repository.py
+5
-4
5 additions, 4 deletions
src/pytrxmat/repository.py
tests/test_repository.py
+1
-0
1 addition, 0 deletions
tests/test_repository.py
tests/test_trx.py
+10
-2
10 additions, 2 deletions
tests/test_trx.py
with
16 additions
and
6 deletions
src/pytrxmat/repository.py
+
5
−
4
View file @
84088172
from
pathlib
import
Path
from
typing
import
Dict
,
List
import
functools
from
.trx
import
TRX
class
DateTime
:
...
...
@@ -10,7 +11,7 @@ class DateTime:
@property
def
trx
(
self
)
->
TRX
:
return
TRX
(
self
.
path
/
'
trx.mat
'
)
return
functools
.
partial
(
TRX
,
self
.
path
/
'
trx.mat
'
)
class
Protocol
:
def
__init__
(
self
,
name
:
str
,
root
:
Path
):
...
...
@@ -34,7 +35,7 @@ class Line:
self
.
name
=
name
self
.
root
=
root
assert
(
str
(
root
.
name
)
==
name
)
self
.
_protocols
:
Dict
[
str
,
Protocol
]
=
{
p
.
name
:
Protocol
(
p
.
name
,
p
)
for
p
in
self
.
root
.
glob
(
'
p_*
'
)
if
p
.
is_dir
()}
self
.
_protocols
:
Dict
[
str
,
Protocol
]
=
{
p
.
name
:
Protocol
(
p
.
name
,
p
)
for
p
in
self
.
root
.
iterdir
(
)
if
p
.
is_dir
()
and
(
p
.
name
.
startswith
(
'
p_
'
)
or
p
.
name
.
startswith
(
'
ch_
'
))
}
def
__getitem__
(
self
,
protocol
:
str
)
->
Protocol
:
return
self
.
_protocols
[
protocol
]
...
...
@@ -82,8 +83,8 @@ class Tracker:
class
Repository
:
def
__init__
(
self
,
root
:
Path
,
trackers
:
List
[
str
]):
self
.
root
=
root
def
__init__
(
self
,
root
,
trackers
:
List
[
str
]):
self
.
root
=
Path
(
root
)
self
.
_trackers
:
Dict
[
str
,
Tracker
]
=
{
t
:
Tracker
(
t
,
self
.
root
/
t
)
for
t
in
trackers
if
(
self
.
root
/
t
in
self
.
root
.
iterdir
())
and
(
self
.
root
/
t
).
is_dir
()}
def
__getitem__
(
self
,
tracker
:
str
)
->
Tracker
:
...
...
This diff is collapsed.
Click to expand it.
tests/test_repository.py
+
1
−
0
View file @
84088172
...
...
@@ -52,5 +52,6 @@ def test_repository(root):
print
(
dt
)
for
trx
in
repo
.
trx
():
print
(
trx
)
print
(
trx
())
print
(
repo
[
'
t1
'
][
'
a@a
'
][
'
p_0
'
][
'
00000000_000000
'
].
trx
)
This diff is collapsed.
Click to expand it.
tests/test_trx.py
+
10
−
2
View file @
84088172
...
...
@@ -65,11 +65,19 @@ def test_get_string_asarray_false(trx: TRX):
s
=
trx
.
get_string
([
'
neuron
'
,
'
protocol
'
],
asarray
=
False
)
print
(
s
)
def
test_larva_filtering
(
trx
:
TRX
):
larvae
=
trx
.
get_as_array
(
'
numero_larva_num
'
)
larva
=
larvae
[
0
].
item
()
x
=
trx
.
get_as_array
([
'
t
'
,
'
x_head
'
],
l
=
[
larva
])[
0
]
print
(
x
)
if
__name__
==
'
__main__
'
:
trx
=
TRX
(
'
trx.mat
'
)
trx
=
TRX
(
'
tests/
trx.mat
'
)
test_get_scalar_list_larvae
(
trx
)
test_get_ts_list_larvae
(
trx
)
test_get_ts_and_scalar
(
trx
)
test_get_bunched_scalar
(
trx
)
test_get_string
(
trx
)
test_get_string_asarray_false
(
trx
)
\ No newline at end of file
test_get_string_asarray_false
(
trx
)
test_larva_filtering
(
trx
)
\ No newline at end of file
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