From aad1b919ca1b04d37d88432225ee4486ac03a9f9 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Bayle <j2b.bayle@gmail.com>
Date: Fri, 6 May 2022 18:03:39 +0200
Subject: [PATCH] Fix a bug with dict-type metadata

---
 lisainstrument/instrument.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py
index 8b1ec63..a7ab46f 100755
--- a/lisainstrument/instrument.py
+++ b/lisainstrument/instrument.py
@@ -1629,7 +1629,11 @@ class Instrument:
             names* (str): attribute names
         """
         for name in names:
-            hdf5.attrs[name] = self.__getattribute__(name)
+            value = self.__getattribute__(name)
+            # Take string representation for non-native types
+            if not isinstance(value, (int, float, np.ndarray)):
+                value = str(value)
+            hdf5.attrs[name] = value
 
     def _write_metadata(self, hdf5):
         """Write relevant object's attributes as metadata on ``hdf5``.
-- 
GitLab