Skip to content

Commit bc3dbbb

Browse files
committed
[evt] improve function expression parsing and remove unneeded typecast
1 parent e485dae commit bc3dbbb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/pygama/evt/build_evt.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,12 @@ def evaluate_expression(
414414
# pygama.evt.modules.spms.my_func([...], arg1=val, arg2=val)
415415

416416
# get arguments list passed to the function (outermost parentheses)
417-
args_str = re.search(r"\((.*)\)$", expr.strip()).group(1)
417+
result = re.search(r"\((.*)\)$", expr.strip(), re.DOTALL)
418+
if result is None:
419+
msg = f"could not parse the function arguments in '{expr}'"
420+
raise RuntimeError(msg)
421+
422+
args_str = result.group(1)
418423

419424
# handle tier scoping: evt.<>
420425
args_str = args_str.replace("evt.", "")

src/pygama/evt/modules/spms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def gather_pulse_data(
140140
pulse_mask = pulse_mask.view_as("ak")
141141

142142
# apply the mask
143-
data = data[ak.values_astype(pulse_mask, bool)]
143+
data = data[pulse_mask]
144144

145145
# remove empty arrays = table_names with no pulses
146146
if drop_empty:

0 commit comments

Comments
 (0)