Skip to content
Snippets Groups Projects
Commit 1f5a0031 authored by johannes bilk's avatar johannes bilk
Browse files

updated the ‘where’ method, filter arguments don’t need to have spaces around the operator anymore

parent 0b13f59f
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ from numpy.typing import ArrayLike
import uproot as ur
from concurrent.futures import ThreadPoolExecutor
from typing import Any, Iterable
import re
class Rootable:
......@@ -187,7 +188,13 @@ class Rootable:
# Applying the conditions to create the mask
for condition in conditions:
key, op, value = condition.split(None, 2) # Split by the first two spaces only
match = re.match(r'(\w+)\s*([<>=]=?| in )\s*(.+)', condition)
if match is None:
raise ValueError(f"Invalid condition: {condition}")
key, op, value = match.groups()
op = op.strip() # remove any leading and trailing spaces
if op == 'in':
value = eval(value)
mask &= np.isin(self.data[key], value)
......
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