Skip to content

Commit fd23821

Browse files
committed
fix: wrap eval() in _locate_cohorts for clearer errors
Signed-off-by: Suhrid Marwah <suhridmarwah07@gmail.com>
1 parent 84d190d commit fd23821

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

malariagen_data/anoph/sample_metadata.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1839,7 +1839,12 @@ def _locate_cohorts(*, cohorts, data, min_cohort_size):
18391839
# to pandas queries.
18401840

18411841
for coh, query in cohorts.items():
1842-
loc_coh = data.eval(query).values
1842+
try:
1843+
loc_coh = data.eval(query).values
1844+
except Exception as e:
1845+
raise ValueError(
1846+
f"Invalid query for cohort {coh!r}: {query!r}. Error: {e}"
1847+
) from e
18431848
coh_dict[coh] = loc_coh
18441849

18451850
else:

0 commit comments

Comments
 (0)