From bf5bf11fc04cb3d6a96ee0e0024a9316a972fbcb Mon Sep 17 00:00:00 2001 From: mloubout Date: Tue, 21 May 2024 00:36:26 -0400 Subject: [PATCH] api: avoid duplicate properties --- devito/types/dense.py | 52 +++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/devito/types/dense.py b/devito/types/dense.py index bf8c6efe9b..0a5385b7a5 100644 --- a/devito/types/dense.py +++ b/devito/types/dense.py @@ -204,6 +204,10 @@ def coefficients(self): """Form of the coefficients of the function.""" return self._coefficients + @property + def _shape_with_outhalo(self): + return self.shape_with_halo + @cached_property def shape(self): """ @@ -231,27 +235,19 @@ def shape_domain(self): @cached_property def shape_with_halo(self): - return tuple(j + i + k for i, (j, k) in zip(self.shape, self._size_outhalo)) + """ + Shape of the domain+outhalo region. The outhalo is the region + surrounding the domain that may be read by an Operator. - @cached_property - def _shape_with_outhalo(self): + Notes + ----- + In an MPI context, this is the *local* with_halo region shape. + Further, note that the outhalo of inner ranks is typically empty, while + the outhalo of boundary ranks contains a number of elements depending + on the rank position in the decomposed grid (corner, side, ...). + """ return tuple(j + i + k for i, (j, k) in zip(self.shape, self._size_outhalo)) - _shape_with_halo_docstring = """\ - Shape of the domain+outhalo region. The outhalo is the region - surrounding the domain that may be read by an Operator. - - Notes - ----- - In an MPI context, this is the *local* with_halo region shape. - Further, note that the outhalo of inner ranks is typically empty, while - the outhalo of boundary ranks contains a number of elements depending - on the rank position in the decomposed grid (corner, side, ...). - """ - - shape_with_halo.__doc__ = _shape_with_halo_docstring - _shape_with_outhalo.__doc__ = _shape_with_halo_docstring - @cached_property def _shape_with_inhalo(self): """ @@ -317,25 +313,13 @@ def size_global(self): """ return reduce(mul, self.shape_global) - @cached_property + @property def _offset_inhalo(self): - """Number of points before the first and last halo elements.""" - left = tuple(self._size_padding.left) - right = tuple(np.add(np.add(left, self._size_halo.left), self._size_domain)) - - offsets = tuple(Offset(i, j) for i, j in zip(left, right)) + return super()._offset_halo - return DimensionTuple(*offsets, getters=self.dimensions, left=left, right=right) - - @cached_property + @property def _size_inhalo(self): - """Number of points in the halo region.""" - left = tuple(zip(*self._halo))[0] - right = tuple(zip(*self._halo))[1] - - sizes = tuple(Size(i, j) for i, j in self._halo) - - return DimensionTuple(*sizes, getters=self.dimensions, left=left, right=right) + return super()._size_halo @cached_property def _size_outhalo(self):