Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alibylite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Swain Lab
aliby
alibylite
Commits
1bf91093
Commit
1bf91093
authored
2 years ago
by
Alán Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
clean(chainer): remove comments and 1/0
parent
064c5b73
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/postprocessor/chainer.py
+18
-46
18 additions, 46 deletions
src/postprocessor/chainer.py
with
18 additions
and
46 deletions
src/postprocessor/chainer.py
+
18
−
46
View file @
1bf91093
...
@@ -17,61 +17,36 @@ from postprocessor.core.lineageprocess import LineageProcessParameters
...
@@ -17,61 +17,36 @@ from postprocessor.core.lineageprocess import LineageProcessParameters
class
Chainer
(
Signal
):
class
Chainer
(
Signal
):
"""
"""
Extend Signal by applying post-processes and allowing composite signals that combine basic signals.
Extend Signal by applying post-processes and allowing composite signals that combine basic signals.
It
"
chains
"
multiple processes upon fetching a dataset to produce the desired datasets.
Instead of reading processes previously applied, it executes
Instead of reading processes previously applied, it executes
them when called.
them when called.
"""
"""
equivalence
s
=
{
_synonym
s
=
{
"
m5m
"
:
(
"
extraction/GFP/max/max5px
"
,
"
extraction/GFP/max/median
"
)
"
m5m
"
:
(
"
extraction/GFP/max/max5px
"
,
"
extraction/GFP/max/median
"
)
}
}
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
super
().
__init__
(
*
args
,
**
kwargs
)
for
channel
in
self
.
candidate_channels
:
# find first channel in h5 file that corresponds to a candidate_channel
# but channel is redefined. why is there a loop over candidate channels?
# what about capitals?
try
:
channel
=
[
ch
for
ch
in
self
.
channels
if
re
.
match
(
"
channel
"
,
ch
)
][
0
]
break
except
:
# is this still a good idea?
pass
try
:
# what's this?
# composite statistic comprising the quotient of two others
equivalences
=
{
"
m5m
"
:
(
f
"
extraction/
{
channel
}
/max/max5px
"
,
f
"
extraction/
{
channel
}
/max/median
"
,
),
}
def
replace_path
(
path
:
str
,
bgsub
:
bool
=
""
):
# function to add bgsub to paths
# function to add bgsub to paths
def
replace_path
(
path
:
str
,
bgsub
:
str
=
""
):
channel
=
path
.
split
(
"
/
"
)[
1
]
channel
=
path
.
split
(
"
/
"
)[
1
]
suffix
=
"
_bgsub
"
if
bgsub
else
""
if
"
bgsub
"
in
bgsub
:
path
=
re
.
sub
(
channel
,
f
"
{
channel
}{
suffix
}
"
,
path
)
# add bgsub to path
return
path
path
=
re
.
sub
(
channel
,
f
"
{
channel
}
_bgsub
"
,
path
)
return
path
# Add chain with and without bgsub for composite statistics
self
.
common_chains
=
{
# for composite statistics
alias
# add chain with and without bgsub
+
bgsub
:
lambda
**
kwargs
:
self
.
get
(
self
.
common_chains
=
{
replace_path
(
denominator
,
alias
+
bgsub
),
**
kwargs
alias
)
+
bgsub
:
lambda
**
kwargs
:
self
.
get
(
/
self
.
get
(
replace_path
(
numerator
,
alias
+
bgsub
),
**
kwargs
)
replace_url
(
denominator
,
alias
+
bgsub
),
**
kwargs
for
alias
,
(
denominator
,
numerator
)
in
self
.
synonyms
.
items
()
)
for
bgsub
in
(
""
,
"
_bgsub
"
)
/
self
.
get
(
replace_path
(
numerator
,
alias
+
bgsub
),
**
kwargs
)
}
for
alias
,
(
denominator
,
numerator
)
in
equivalences
.
items
()
for
bgsub
in
(
""
,
"
_bgsub
"
)
}
except
:
# Is this still a good idea?
pass
def
get
(
def
get
(
self
,
self
,
...
@@ -83,7 +58,6 @@ class Chainer(Signal):
...
@@ -83,7 +58,6 @@ class Chainer(Signal):
**
kwargs
,
**
kwargs
,
):
):
"""
Load data from an h5 file.
"""
"""
Load data from an h5 file.
"""
1
/
0
if
dataset
in
self
.
common_chains
:
if
dataset
in
self
.
common_chains
:
# get dataset for composite chains
# get dataset for composite chains
data
=
self
.
common_chains
[
dataset
](
**
kwargs
)
data
=
self
.
common_chains
[
dataset
](
**
kwargs
)
...
@@ -149,7 +123,5 @@ class Chainer(Signal):
...
@@ -149,7 +123,5 @@ class Chainer(Signal):
if
process_type
==
"
reshapers
"
:
if
process_type
==
"
reshapers
"
:
if
process
==
"
merger
"
:
if
process
==
"
merger
"
:
raise
(
NotImplementedError
)
raise
(
NotImplementedError
)
merges
=
process
.
as_function
(
result
,
**
params
)
result
=
self
.
apply_merges
(
result
,
merges
)
self
.
_intermediate_steps
.
append
(
result
)
self
.
_intermediate_steps
.
append
(
result
)
return
result
return
result
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