Skip to content

Commit e9a8c9b

Browse files
committed
promote stats keys to class attribute for reusability
1 parent f5c4071 commit e9a8c9b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/mdio/api/accessor.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ class MDIOAccessor:
129129
we can directly unpack it and use it further down our code.
130130
"""
131131

132+
_stats_keys = {"mean", "std", "rms", "min", "max"}
133+
132134
_array_load_function_mapper = {
133135
"zarr": open_zarr_array,
134136
"dask": open_zarr_array_dask,
@@ -362,15 +364,14 @@ def chunks(self, value: tuple[int, ...]) -> None:
362364
@property
363365
def stats(self) -> dict:
364366
"""Get global statistics like min/max/rms/std."""
365-
keys = {"mean", "std", "rms", "min", "max"}
366-
return {key: self.root.attrs[key] for key in keys}
367+
return {key: self.root.attrs[key] for key in self._stats_keys}
367368

368369
@stats.setter
369370
def stats(self, value: dict) -> None:
370371
"""Set global statistics like min/max/rms/std."""
371-
keys = {"mean", "std", "rms", "min", "max"}
372-
if not isinstance(value, dict) or not keys.issubset(value.keys()):
373-
raise AttributeError(f"For settings status, you must provide keys: {keys}")
372+
if not isinstance(value, dict) or not self._stats_keys.issubset(value.keys()):
373+
msg = f"For settings status, you must provide keys: {self._stats_keys}"
374+
raise AttributeError(msg)
374375
self.root.attrs.update(value)
375376
self._consolidate_metadata()
376377

0 commit comments

Comments
 (0)