Skip to content

Commit

Permalink
simpler client case
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Feb 3, 2024
1 parent 4bb039e commit 7d919b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pyphare/pyphare/pharesee/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ def __init__(
self.refinement_ratio = refinement_ratio

self.data_files = {}
self._sim = None

if data_files is not None:
self.data_files.update(data_files)
Expand Down Expand Up @@ -608,6 +609,21 @@ def __init__(
def __getitem__(self, qty):
return self.__dict__[qty]

@property
def sim(self):
if self._sim:
return self._sim

if "py_attrs" not in self.data_files:
raise ValueError("Simulation is not available for deserialization")

from ..pharein.simulation import deserialize

self._sim = deserialize(
self.data_files["py_attrs"].attrs["serialized_simulation"]
)
return self._sim

def __call__(self, qty=None, **kwargs):
# take slice/slab of 1/2d array from 2/3d array
def cuts(c, coord):
Expand Down
3 changes: 3 additions & 0 deletions tests/simulator/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ def _test_dump_diags(self, dim, **simInput):
)

hier = hierarchy_from(h5_filename=h5_filepath)

assert hier.sim.electrons.closure.Te == 0.12

if h5_filepath.endswith("domain.h5"):
particle_files += 1
self.assertTrue("pop_mass" in h5_file.attrs)
Expand Down

0 comments on commit 7d919b5

Please sign in to comment.