diff --git a/src/cal_tools/calcat_interface.py b/src/cal_tools/calcat_interface.py index aabee45033593c22797bc97362ed06f6517108a6..c536c5d806ae0c94ba70c86312a2abb8a07a0a25 100644 --- a/src/cal_tools/calcat_interface.py +++ b/src/cal_tools/calcat_interface.py @@ -119,10 +119,24 @@ class CalCatApi(metaclass=ClientWrapper): Returns: (dict) Operating condition for use in CalCat API. """ + import numpy as np + + def make_serializable(value): + if isinstance(value, (np.float32, np.float64)): + return float(value) + elif isinstance(value, np.integer): + return int(value) + elif isinstance(value, (np.ndarray,)): + return value.tolist() + elif isinstance(value, (np.bool_, bool)): + return int(value) + return value + + for k, v in condition.items(): return { "parameters_conditions_attributes": [ - {"parameter_name": k, "value": str(v)} + {"parameter_name": k, "value": make_serializable(v)} for k, v in condition.items() ] }