Skip to content
Snippets Groups Projects
Commit 1bf91093 authored by Alán Muñoz's avatar Alán Muñoz
Browse files

clean(chainer): remove comments and 1/0

parent 064c5b73
No related branches found
No related tags found
No related merge requests found
...@@ -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.
""" """
equivalences = { _synonyms = {
"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
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