From 04cab3cf79bafec7cd91bf02a216a930b1aae117 Mon Sep 17 00:00:00 2001
From: Fabian Reister <fabian.reister@kit.edu>
Date: Mon, 3 Feb 2025 18:23:21 +0100
Subject: [PATCH 1/2] fix by TB: microphone_to_memory does not work otherwise

---
 armarx_memory/aron/conversion/pythonic_from_to_aron_ice.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/armarx_memory/aron/conversion/pythonic_from_to_aron_ice.py b/armarx_memory/aron/conversion/pythonic_from_to_aron_ice.py
index 36e2eb31..2c6c2bff 100644
--- a/armarx_memory/aron/conversion/pythonic_from_to_aron_ice.py
+++ b/armarx_memory/aron/conversion/pythonic_from_to_aron_ice.py
@@ -29,7 +29,6 @@ def pythonic_to_aron_ice(
     elif isinstance(value, np.int64):
         return AronDataIceTypes.long(int(value))
     elif isinstance(value, int) or isinstance(value, np.int32):
-        assert(isinstance(value, int)), value
         assert 'invalid value - expected int' not in str(AronIceTypes.int(int(value))), \
             f'Casting {value} to int failed. Did you intend to use np.int64 instead, ' \
             'but assigned a plain int value, or converted the value somewhere in the meantime?'
-- 
GitLab


From 9e1566594930112fa07e0c5029268a514b5fb188 Mon Sep 17 00:00:00 2001
From: Joana Plewnia <joana.plewnia@kit.edu>
Date: Tue, 4 Feb 2025 08:10:28 +0100
Subject: [PATCH 2/2] extracted np.int32 conversion to separate case

---
 .../conversion/pythonic_from_to_aron_ice.py    | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/armarx_memory/aron/conversion/pythonic_from_to_aron_ice.py b/armarx_memory/aron/conversion/pythonic_from_to_aron_ice.py
index 2c6c2bff..95deb264 100644
--- a/armarx_memory/aron/conversion/pythonic_from_to_aron_ice.py
+++ b/armarx_memory/aron/conversion/pythonic_from_to_aron_ice.py
@@ -28,11 +28,21 @@ def pythonic_to_aron_ice(
         return AronDataIceTypes.bool(value)
     elif isinstance(value, np.int64):
         return AronDataIceTypes.long(int(value))
-    elif isinstance(value, int) or isinstance(value, np.int32):
-        assert 'invalid value - expected int' not in str(AronIceTypes.int(int(value))), \
-            f'Casting {value} to int failed. Did you intend to use np.int64 instead, ' \
-            'but assigned a plain int value, or converted the value somewhere in the meantime?'
+    elif isinstance(value, np.int32):
         return AronIceTypes.int(int(value))
+    elif isinstance(value, int):
+        # because python is treating int and long the same, we need to differentiate between the two
+        if 'invalid value - expected int' in str(AronIceTypes.int(int(value))):
+            # try to convert it to AronInt -> if it fails this is a long
+            assert 'invalid value - expected int' not in str(AronIceTypes.long(int(value))), \
+                f'Casting {value} to long failed. Did you intend to use np.int64 instead, ' \
+                'but assigned a plain int value, or converted the value somewhere in the meantime?'
+            return AronIceTypes.long(int(value))
+        else:
+            assert 'invalid value - expected int' not in str(AronIceTypes.int(int(value))), \
+                f'Casting {value} to int failed. Did you intend to use np.int64 instead, ' \
+                'but assigned a plain int value, or converted the value somewhere in the meantime?'
+            return AronIceTypes.int(int(value))
     elif isinstance(value, np.float64):
         return AronDataIceTypes.double(float(value))
     elif isinstance(value, float) or isinstance(value, np.float32):
-- 
GitLab