Skip to content

Commit

Permalink
Update metric argument cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
jteijema authored Feb 6, 2025
1 parent c415c8d commit 3825d67
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions asreviewcontrib/insights/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,19 @@ def get_metrics(
y_absolute=False,
version=None,
):
recall = (
[recall]
if recall and not isinstance(recall, list)
else [0.1, 0.25, 0.5, 0.75, 0.9]
)
wss = [wss] if wss and not isinstance(wss, list) else [0.95]
erf = [erf] if erf and not isinstance(erf, list) else [0.10]
cm = [cm] if cm and not isinstance(cm, list) else [0.1, 0.25, 0.5, 0.75, 0.9]
def ensure_list_of_floats(value, default):
if value is None:
return default
if isinstance(value, float):
return [value]
if isinstance(value, list) and all(isinstance(i, float) for i in value):
return value
raise ValueError(f"Invalid input: {value}. Must be a float or a list of floats.")

recall = ensure_list_of_floats(recall, [0.1, 0.25, 0.5, 0.75, 0.9])
wss = ensure_list_of_floats(wss, [0.95])
erf = ensure_list_of_floats(erf, [0.10])
cm = ensure_list_of_floats(cm, [0.1, 0.25, 0.5, 0.75, 0.9])

labels = _pad_simulation_labels(state_obj, priors=priors)

Expand Down

0 comments on commit 3825d67

Please sign in to comment.