Skip to content

Commit 0cdeb54

Browse files
committed
bug fix
1 parent 21b8f21 commit 0cdeb54

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/boostedhh/utils.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,16 @@ def format_columns(columns: list):
420420
return ret_columns
421421

422422

423+
# add OR filter to each inner filter list
424+
def add_or_filter(filters, cut: list[tuple]):
425+
if isinstance(filters[0], list):
426+
# recursively handle nested filter lists
427+
return [add_or_filter(f, cut) for f in filters]
428+
else:
429+
# add OR filter at leaf level
430+
return filters + cut
431+
432+
423433
def _normalize_weights(
424434
events: pd.DataFrame,
425435
year: str,
@@ -514,9 +524,11 @@ def load_sample(
514524

515525
# find the directory that contains the sample
516526
for sp in sample_path:
517-
spy = sp / year
518-
full_samples_list = listdir(spy) # get all directories in data_dir
519-
load_samples = [str(s) for s in full_samples_list if sample.get_selector(year).match(s)]
527+
spy = Path(sp) / year
528+
full_samples_list = list(spy.iterdir()) # get all directories in data_dir
529+
load_samples = [
530+
s.name for s in full_samples_list if sample.get_selector(year).match(s.name)
531+
]
520532
if len(load_samples):
521533
sample_path = spy
522534
break

0 commit comments

Comments
 (0)