Skip to content

Commit fdf8597

Browse files
authored
fix: set dict correctly when unserializing (#1040)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent ef876c9 commit fdf8597

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/boost_histogram/axis/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __setattr__(self, attr: str, value: Any) -> None:
9696

9797
def __getattr__(self, attr: str) -> Any:
9898
if attr == "metadata":
99-
return
99+
return None
100100
raise AttributeError(
101101
f"object {self.__class__.__name__} has no attribute {attr}"
102102
)

src/boost_histogram/serialization/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def from_uhi(data: dict[str, Any], /) -> histogram.Histogram:
3636
h = histogram.Histogram(
3737
*(_axis_from_dict(ax) for ax in data["axes"]),
3838
storage=_storage_from_dict(data["storage"]),
39-
metadata=data.get("metadata"),
4039
)
4140
h[...] = _data_from_dict(data["storage"])
41+
h.__dict__ = data.get("metadata", {})
4242
return h
4343

4444

0 commit comments

Comments
 (0)