From c854c0b9d4e9bc768e85172056f98f5f9e5580e3 Mon Sep 17 00:00:00 2001 From: Olivier Hoenen Date: Fri, 12 Jun 2026 20:35:33 +0200 Subject: [PATCH 1/2] fix deprecation warning with __array__'s copy keyword for Numpy>2 --- imas/ids_primitive.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imas/ids_primitive.py b/imas/ids_primitive.py index a86faa95..8e64a7c6 100644 --- a/imas/ids_primitive.py +++ b/imas/ids_primitive.py @@ -334,7 +334,7 @@ class IDSNumeric0D(IDSPrimitive): __doc__ = IDSDoc(__doc__) __slots__ = () - def __array__(self, dtype=None): + def __array__(self, dtype=None, copy=None): return np.array(self.value, dtype=dtype) def __str__(self): @@ -437,7 +437,9 @@ class IDSNumericArray(IDSPrimitive, np.lib.mixins.NDArrayOperatorsMixin): # list, to support operations like np.add(array_like, list) _HANDLED_TYPES = (np.ndarray, Number) - def __array__(self, dtype=None): + def __array__(self, dtype=None, copy=None): + if copy: + return self.value.astype(dtype, copy=True) return self.value.astype(dtype, copy=False) def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): From 58095b03a0a24a466ccd45ad4de4abf5bf3bef00 Mon Sep 17 00:00:00 2001 From: Olivier Hoenen Date: Mon, 15 Jun 2026 11:46:38 +0200 Subject: [PATCH 2/2] Update imas/ids_primitive.py Co-authored-by: Maarten Sebregts <110895564+maarten-ic@users.noreply.github.com> --- imas/ids_primitive.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/imas/ids_primitive.py b/imas/ids_primitive.py index 8e64a7c6..4843ca02 100644 --- a/imas/ids_primitive.py +++ b/imas/ids_primitive.py @@ -438,9 +438,7 @@ class IDSNumericArray(IDSPrimitive, np.lib.mixins.NDArrayOperatorsMixin): _HANDLED_TYPES = (np.ndarray, Number) def __array__(self, dtype=None, copy=None): - if copy: - return self.value.astype(dtype, copy=True) - return self.value.astype(dtype, copy=False) + return self.value.astype(dtype, copy=bool(copy)) def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): out = kwargs.get("out", ())