From 5316660eb1ef9a84a1484293bb23083a85b2b60d Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Thu, 29 Aug 2024 10:15:05 +0100 Subject: [PATCH] DatView: Fix zero() --- pyop2/types/dat.py | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/pyop2/types/dat.py b/pyop2/types/dat.py index 5ee339bcc..11214c2ec 100644 --- a/pyop2/types/dat.py +++ b/pyop2/types/dat.py @@ -681,6 +681,7 @@ def __init__(self, dat, index): if not (0 <= i < d): raise ex.IndexValueError("Can't create DatView with index %s for Dat with shape %s" % (index, dat.dim)) self.index = index + self._idx = (slice(None), *index) self._parent = dat # Point at underlying data super(DatView, self).__init__(dat.dataset, @@ -722,39 +723,11 @@ def halo_valid(self, value): @property def data(self): - full = self._parent.data - idx = (slice(None), *self.index) - return full[idx] + return self._parent.data[self._idx] @property - def data_ro(self): - full = self._parent.data_ro - idx = (slice(None), *self.index) - return full[idx] - - @property - def data_wo(self): - full = self._parent.data_wo - idx = (slice(None), *self.index) - return full[idx] - - @property - def data_with_halos(self): - full = self._parent.data_with_halos - idx = (slice(None), *self.index) - return full[idx] - - @property - def data_ro_with_halos(self): - full = self._parent.data_ro_with_halos - idx = (slice(None), *self.index) - return full[idx] - - @property - def data_wo_with_halos(self): - full = self._parent.data_wo_with_halos - idx = (slice(None), *self.index) - return full[idx] + def _data(self): + return self._parent._data[self._idx] class Dat(AbstractDat, VecAccessMixin):