Skip to content

Commit b5bd2fb

Browse files
committed
add error messaging around use of get data in templates
1 parent 4a1a45a commit b5bd2fb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/spikeinterface/core/analyzer_extension_core.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,12 @@ def _set_params(self, ms_before: float = 1.0, ms_after: float = 2.0, operators=N
380380
assert isinstance(operators, list)
381381
for operator in operators:
382382
if isinstance(operator, str):
383-
assert operator in ("average", "std", "median", "mad")
383+
if operator not in ("average", "std", "median", "mad"):
384+
error_msg = (
385+
f"You have entered an operator {operator} in your `operators` argument which is "
386+
f"not supported. Please use any of ['average', 'std', 'median', 'mad'] instead."
387+
)
388+
raise ValueError(error_msg)
384389
else:
385390
assert isinstance(operator, (list, tuple))
386391
assert len(operator) == 2
@@ -549,9 +554,17 @@ def _get_data(self, operator="average", percentile=None, outputs="numpy"):
549554
if operator != "percentile":
550555
key = operator
551556
else:
552-
assert percentile is not None, "You must provide percentile=..."
557+
assert percentile is not None, "You must provide percentile=... if `operator=percentile`"
553558
key = f"percentile_{percentile}"
554559

560+
if key not in self.data.keys():
561+
error_msg = (
562+
f"You have entered `operator={key}`, but the only operators calculated are "
563+
f"{list(self.data.keys())}. Please use one of these as your `operator` in the "
564+
f"`get_data` function."
565+
)
566+
raise ValueError(error_msg)
567+
555568
templates_array = self.data[key]
556569

557570
if outputs == "numpy":

0 commit comments

Comments
 (0)