From e7d1b0e2fa36722d7761d64821a6d8975e756af0 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Thu, 6 Jun 2024 10:56:35 +0200
Subject: [PATCH] fix: instead of converting to str, serializable values

---
 src/cal_tools/calcat_interface.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/cal_tools/calcat_interface.py b/src/cal_tools/calcat_interface.py
index aabee4503..c536c5d80 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()
             ]
         }
-- 
GitLab