From 1beeab44a2a6741fc2fb6868da6f87339925a1e6 Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Mon, 18 Sep 2023 17:54:41 +0200 Subject: [PATCH] try to be more robust in handling unexpected values --- api/data_models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/data_models.py b/api/data_models.py index 1e2b0b9..30ee1fb 100644 --- a/api/data_models.py +++ b/api/data_models.py @@ -96,7 +96,9 @@ def from_neo(cls, signal, down_sample_factor): "times_dimensionality": str(signal.t_start.units.dimensionality), "values_units": str(signal.units.dimensionality), } - if down_sample_factor in (None, ""): + try: + down_sample_factor = int(down_sample_factor) + except (ValueError, TypeError): down_sample_factor = 1 if isinstance(signal, neo.AnalogSignal): data["sampling_period"] = (