@@ -638,11 +638,12 @@ def _sdat_from_conf(core: Core) -> StagyyData:
638638 return StagyyData (core .path , core .read_parameters_dat )
639639
640640
641+ @dataclass (frozen = True )
641642class StagyyData :
642643 """Generic lazy interface to StagYY output data.
643644
644645 Args:
645- path : path of the StagYY run. It can either be the path of the
646+ path_hint : path of the StagYY run. It can either be the path of the
646647 directory containing the par file, or the path of the par file. If
647648 the path given is a directory, the path of the par file is assumed
648649 to be path/par.
@@ -653,27 +654,21 @@ class StagyyData:
653654 logic.
654655 """
655656
656- def __init__ (self , path : PathLike , read_parameters_dat : bool = True ):
657- self ._parpath = Path (path )
658- if not self ._parpath .is_file ():
659- self ._parpath /= "par"
660- self ._read_parameters_dat = read_parameters_dat
661-
662- def __repr__ (self ) -> str :
663- return f"StagyyData({ self .path !r} )"
664-
665- def __str__ (self ) -> str :
666- return f"StagyyData in { self .path } "
657+ path_hint : PathLike | str
658+ read_parameters_dat : bool = True
667659
668660 @property
669661 def path (self ) -> Path :
670662 """Path of StagYY run directory."""
671- return self ._parpath .parent
663+ return self .parpath .parent
672664
673- @property
665+ @cached_property
674666 def parpath (self ) -> Path :
675667 """Path of par file."""
676- return self ._parpath
668+ parpath = Path (self .path_hint )
669+ if parpath .is_file ():
670+ return parpath
671+ return parpath / "par"
677672
678673 @cached_property
679674 def hdf5 (self ) -> Path | None :
@@ -732,7 +727,7 @@ def _traxmf(self) -> TracersXmf:
732727 @cached_property
733728 def par (self ) -> StagyyPar :
734729 """Content of par file."""
735- return StagyyPar .from_main_par (self .parpath , self ._read_parameters_dat )
730+ return StagyyPar .from_main_par (self .parpath , self .read_parameters_dat )
736731
737732 @cached_property
738733 def _rprof_and_times (self ) -> tuple [dict [int , DataFrame ], DataFrame | None ]:
0 commit comments