Skip to content

Commit

Permalink
DatView: Fix zero()
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Aug 29, 2024
1 parent 5f18075 commit 09f4643
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions pyop2/types/dat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -722,39 +723,31 @@ 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]
return self._parent.data_ro[self._idx]

@property
def data_wo(self):
full = self._parent.data_wo
idx = (slice(None), *self.index)
return full[idx]
return self._parent.data_wo[self._idx]

@property
def data_with_halos(self):
full = self._parent.data_with_halos
idx = (slice(None), *self.index)
return full[idx]
return self._parent.data_with_halos[self._idx]

@property
def data_ro_with_halos(self):
full = self._parent.data_ro_with_halos
idx = (slice(None), *self.index)
return full[idx]
return self._parent.data_ro_with_halos[self._idx]

@property
def data_wo_with_halos(self):
full = self._parent.data_wo_with_halos
idx = (slice(None), *self.index)
return full[idx]
return self._parent.data_wo_with_halos[self._idx]

@property
def _data(self):
return self._parent._data[self._idx]


class Dat(AbstractDat, VecAccessMixin):
Expand Down

0 comments on commit 09f4643

Please sign in to comment.