Skip to content

Commit

Permalink
oct_handler should be a read-only property
Browse files Browse the repository at this point in the history
  • Loading branch information
cphyc committed Nov 6, 2023
1 parent 1f11677 commit 2c32713
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
9 changes: 5 additions & 4 deletions yt/data_objects/index_subobjects/octree_subset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import abc
from contextlib import contextmanager
from functools import cached_property
from itertools import product, repeat
Expand Down Expand Up @@ -33,7 +34,7 @@ def cc_cache_func(self, dobj):
return cc_cache_func


class OctreeSubset(YTSelectionContainer):
class OctreeSubset(YTSelectionContainer, abc.ABC):
_spatial = True
_num_ghost_zones = 0
_type_name = "octree_subset"
Expand All @@ -57,10 +58,10 @@ def __init__(self, base_region, domain, ds, num_zones=2, num_ghost_zones=0):
self.base_selector = base_region.selector

@property
@abc.abstractmethod
def oct_handler(self):
# Use an indirection so that oct_handler
# doesn't have to exist when we create the subset
return self.domain.oct_handler
# In charge of returning the oct_handler
pass

def __getitem__(self, key):
tr = super().__getitem__(key)
Expand Down
6 changes: 5 additions & 1 deletion yt/frontends/art/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,11 @@ def __init__(self, ds, nvar, oct_handler, domain_id):
self._level_count = None
self._level_oct_offsets = None
self._level_child_offsets = None
self.oct_handler = oct_handler
self._oct_handler = oct_handler

@property
def oct_handler(self):
return self._oct_handler

@property
def level_count(self):
Expand Down
6 changes: 5 additions & 1 deletion yt/frontends/artio/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, base_region, sfc_start, sfc_end, oct_handler, ds):
self.field_parameters = {}
self.sfc_start = sfc_start
self.sfc_end = sfc_end
self.oct_handler = oct_handler
self._oct_handler = oct_handler
self.ds = ds
self._last_mask = None
self._last_selector_id = None
Expand All @@ -43,6 +43,10 @@ def __init__(self, base_region, sfc_start, sfc_end, oct_handler, ds):
self.base_region = base_region
self.base_selector = base_region.selector

@property
def oct_handler(self):
return self._oct_handler

@property
def min_ind(self):
return self.sfc_start
Expand Down
5 changes: 4 additions & 1 deletion yt/frontends/ramses/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def __init__(self, ds, domain_id):
"Detected particle type %s in domain_id=%s", ph.ptype, domain_id
)
ph.read_header()
# self._add_ptype(ph.ptype)

def __repr__(self):
return "RAMSESDomainFile: %i" % self.domain_id
Expand Down Expand Up @@ -385,6 +384,10 @@ def __init__(
"of ghost zones, was called with num_ghost_zones=%s" % num_ghost_zones
)

@property
def oct_handler(self):
return self.domain.oct_handler

def _fill_no_ghostzones(self, fd, fields, selector, file_handler):
ndim = self.ds.dimensionality
# Here we get a copy of the file, which we skip through and read the
Expand Down
6 changes: 1 addition & 5 deletions yt/frontends/stream/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ def __init__(self, base_region, ds, oct_handler, num_zones=2, num_ghost_zones=0)
self.field_data = YTFieldData()
self.field_parameters = {}
self.ds = ds
self.oct_handler = oct_handler
self._oct_handler = oct_handler
self._last_mask = None
self._last_selector_id = None
self._current_particle_type = "io"
Expand All @@ -788,10 +788,6 @@ def __init__(self, base_region, ds, oct_handler, num_zones=2, num_ghost_zones=0)
def oct_handler(self):
return self._oct_handler

@oct_handler.setter
def oct_handler(self, oh):
self._oct_handler = oh

def retrieve_ghost_zones(self, ngz, fields, smoothed=False):
try:
new_subset = self._subset_with_gz
Expand Down

0 comments on commit 2c32713

Please sign in to comment.