From 7cb6cc1346b1e694b28742856bffc9493d028c79 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 18 Dec 2023 14:09:00 +0000 Subject: [PATCH] a slice of an array of a given type is still of that same type --- autoarray/abstract_ndarray.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoarray/abstract_ndarray.py b/autoarray/abstract_ndarray.py index 2d9c0d7c..42238dca 100644 --- a/autoarray/abstract_ndarray.py +++ b/autoarray/abstract_ndarray.py @@ -239,7 +239,10 @@ def reshape(self, *args, **kwargs): return self._array.reshape(*args, **kwargs) def __getitem__(self, item): - return self._array[item] + result = self._array[item] + if isinstance(item, slice): + return self.with_new_array(result) + return result def __setitem__(self, key, value): if isinstance(key, (np.ndarray, AbstractNDArray, Array)):