Skip to content

Commit 45348ca

Browse files
committed
read_geom_h5 no longer returns the element tree
Since the root element is cached in the FieldXmf object, this is no longer necessary.
1 parent 0eb5ed9 commit 45348ca

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

stagpy/_step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def _header(self) -> Optional[Dict[str, Any]]:
406406
elif self.step.sdat.hdf5:
407407
header = stagyyparsers.read_geom_h5(
408408
self.step.sdat._dataxmf, self.step.isnap
409-
)[0]
409+
)
410410
return header if header else None
411411

412412
@cached_property

stagpy/stagyyparsers.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -864,19 +864,19 @@ def root(self) -> Element:
864864
return xmlET.parse(str(self.path)).getroot()
865865

866866

867-
def read_geom_h5(xdmf: FieldXmf, snapshot: int) -> Tuple[Dict[str, Any], Element]:
867+
def read_geom_h5(xdmf: FieldXmf, snapshot: int) -> dict[str, Any]:
868868
"""Extract geometry information from hdf5 files.
869869
870870
Args:
871871
xdmf_file: path of the xdmf file.
872872
snapshot: snapshot number.
873873
Returns:
874-
geometry information and root of xdmf document.
874+
geometry information.
875875
"""
876876
header: Dict[str, Any] = {}
877877
xdmf_root = xdmf.root
878878
if snapshot is None:
879-
return {}, xdmf_root
879+
return {}
880880

881881
# Domain, Temporal Collection, Snapshot
882882
# should check that this is indeed the required snapshot
@@ -907,7 +907,7 @@ def read_geom_h5(xdmf: FieldXmf, snapshot: int) -> Tuple[Dict[str, Any], Element
907907
coord_shape.append(_get_dim(xdmf.path, data_item))
908908
coord_h5.append(xdmf.path.parent / data_text.strip().split(":/", 1)[0])
909909
_read_coord_h5(coord_h5, coord_shape, header, twod)
910-
return header, xdmf_root
910+
return header
911911

912912

913913
def _to_spherical(flds: ndarray, header: Dict[str, Any]) -> ndarray:
@@ -978,9 +978,8 @@ def read_field_h5(
978978
unavailable.
979979
"""
980980
if header is None:
981-
header, xdmf_root = read_geom_h5(xdmf, snapshot)
982-
else:
983-
xdmf_root = xdmf.root
981+
header = read_geom_h5(xdmf, snapshot)
982+
xdmf_root = xdmf.root
984983

985984
npc = header["nts"] // header["ncs"] # number of grid point per node
986985
flds = np.zeros(_flds_shape(fieldname, header))

0 commit comments

Comments
 (0)