From d09a455b0ecd0aa15aba9e5b11daf1ee370489ce Mon Sep 17 00:00:00 2001 From: Daniel Scheffler <danschef@gfz-potsdam.de> Date: Wed, 14 Jun 2023 17:55:20 +0200 Subject: [PATCH 1/2] Remove GeoArray.arg. Signed-off-by: Daniel Scheffler <danschef@gfz-potsdam.de> --- geoarray/baseclasses.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/geoarray/baseclasses.py b/geoarray/baseclasses.py index f54c03c..dc55346 100644 --- a/geoarray/baseclasses.py +++ b/geoarray/baseclasses.py @@ -111,7 +111,6 @@ class GeoArray(object): else: self._initParams = dict([x for x in locals().items() if x[0] != "self"]) - self.arg = path_or_array self._arr = path_or_array if isinstance(path_or_array, np.ndarray) else None self.filePath = path_or_array if isinstance(path_or_array, str) and path_or_array else None basename_default = os.path.splitext(os.path.basename(self.filePath))[0] if not self.is_inmem else 'IN_MEM' @@ -577,7 +576,7 @@ class GeoArray(object): if self.is_inmem: return self.arr[:, :, given] else: - return self.from_path(self.arg, [given]) + return self.from_path(self.filePath, [given]) elif isinstance(given, str): # behave like a dictionary and return the corresponding band @@ -588,7 +587,7 @@ class GeoArray(object): if self.is_inmem: return self.arr if self.ndim == 2 else self.arr[:, :, self.bandnames[given]] else: - return self.from_path(self.arg, [self.bandnames[given]]) + return self.from_path(self.filePath, [self.bandnames[given]]) else: raise ValueError('String indices are only supported if %s has been instanced with bandnames given.' % self.__class__.__name__) @@ -624,7 +623,7 @@ class GeoArray(object): else: getitem_params = \ given[:2] if (self.ndim == 2 and band_idx == 0) else given[:2] + (band_idx,) - return self.from_path(self.arg, getitem_params) + return self.from_path(self.filePath, getitem_params) else: raise ValueError( 'String indices are only supported if %s has been instanced with bandnames given.' @@ -635,14 +634,14 @@ class GeoArray(object): if self.is_inmem: return self.arr[given[:2]] else: - return self.from_path(self.arg, given[:2]) + return self.from_path(self.filePath, given[:2]) # if nothing has been returned until here -> behave like a numpy array if self.is_inmem: return self.arr[given] else: getitem_params = [given] if isinstance(given, slice) else given - return self.from_path(self.arg, getitem_params) + return self.from_path(self.filePath, getitem_params) def __setitem__(self, idx, array2set): """Overwrite the pixel values of GeoArray.arr with the given array. -- GitLab From d1b69ecba7648b9d6422550da04c1c159a02199d Mon Sep 17 00:00:00 2001 From: Daniel Scheffler <danschef@gfz-potsdam.de> Date: Wed, 14 Jun 2023 17:56:36 +0200 Subject: [PATCH 2/2] Update HISTORY.rst. Signed-off-by: Daniel Scheffler <danschef@gfz-potsdam.de> --- HISTORY.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index e82fd13..3b050f0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,12 @@ History ======= +0.16.2 (coming soon) +-------------------- + +* !38: Removed GeoArray.arg attribute as it is not needed and just consumes memory. + + 0.16.1 (16.02.2023) ------------------- -- GitLab