Skip to content

Commit 701c9c8

Browse files
authored
fix: patch repr on boost-histogram 1.7.0/1.7.1 (#673)
Better repr until 1.7.2 comes out. Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
1 parent e724d73 commit 701c9c8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/hist/basehist.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ def _repr_html_(self) -> str | None:
226226

227227
return None
228228

229+
def __repr__(self) -> str:
230+
# Workaround for boost-histogram 1.7.0 and 1.7.1 having a 0
231+
old_repr = super().__repr__()
232+
if "MultiCell(0)" in old_repr:
233+
nelem = self._hist.nelem()
234+
return old_repr.replace("MultiCell(0)", f"MultiCell({nelem})")
235+
return old_repr
236+
229237
def _name_to_index(self, name: str) -> int:
230238
"""
231239
Transform axis name to axis index, given axis name, return axis \

0 commit comments

Comments
 (0)