From d170f44cce8eacaa14a5b04b10794dcf94bfe752 Mon Sep 17 00:00:00 2001 From: Patrick Krause Date: Tue, 28 Nov 2023 22:05:10 +0100 Subject: [PATCH] stupid dot notation --- src/pygama/evt/build_evt.py | 7 ++++++- src/pygama/evt/modules/legend_meta.py | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/pygama/evt/build_evt.py b/src/pygama/evt/build_evt.py index bec8d1a1a..0288015a0 100644 --- a/src/pygama/evt/build_evt.py +++ b/src/pygama/evt/build_evt.py @@ -108,8 +108,13 @@ def evaluate_expression( if mode == "function": # evaluate expression func, params = expr.split("(") + params = ( + params.replace("dsp.", "dsp_") + .replace("hit.", "hit_") + .replace("evt.", "evt_") + ) params = [f_hit, f_dsp, f_tcm, chns] + [ - num_and_pars(e.replace(".", "_"), var_ph) for e in params[:-1].split(",") + num_and_pars(e, var_ph) for e in params[:-1].split(",") ] # load function dynamically diff --git a/src/pygama/evt/modules/legend_meta.py b/src/pygama/evt/modules/legend_meta.py index 9a001e5cc..d188c2a14 100644 --- a/src/pygama/evt/modules/legend_meta.py +++ b/src/pygama/evt/modules/legend_meta.py @@ -3,18 +3,25 @@ """ from importlib import import_module -def legend_meta(params:dict) -> list: + +def legend_meta(params: dict) -> list: # only import legend meta data when needed. # LEGEND collaborators can use the meta keyword # While for users w/o access to the LEGEND meta data this is still working lm = import_module("legendmeta") lmeta = lm.LegendMetadata(path=params["meta_path"]) - chmap = lmeta.channelmap(params['time_key']) + chmap = lmeta.channelmap(params["time_key"]) tmp = [ f"ch{e}" for e in chmap.map("daq.rawid") - if chmap.map("daq.rawid")[e]["system"] == params['system'] + if chmap.map("daq.rawid")[e]["system"] == params["system"] ] - if 'usability' not in params.keys(): return tmp + if "usability" not in params.keys(): + return tmp else: - return [e for e in tmp if chmap.map("daq.rawid")[int(e[2:])]["analysis"]["usability"] == params['usability']] \ No newline at end of file + return [ + e + for e in tmp + if chmap.map("daq.rawid")[int(e[2:])]["analysis"]["usability"] + == params["usability"] + ]