Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,10 @@ def _axes(self) -> Tuple[Union[PlottableAxisContinuous, PlottableAxisDiscrete],


def _kind(self) -> Kind:
return Kind.COUNT if not _hasWeights(self) else Kind.MEAN
# TProfile -> MEAN, everything else -> COUNT
if self.__class__.__name__.startswith("TProfile"):
return Kind.MEAN
return Kind.COUNT


def _values_default(self) -> np.typing.NDArray[Any]: # noqa: F821
Expand Down
17 changes: 17 additions & 0 deletions bindings/pyroot/pythonizations/test/uhi_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,22 @@ def test_uhi_projection_preserves_content(self):
assert np.allclose(uhi_values, ref_values)


class TestHistogramKind:
def test_histogram_kind_no_weights(self):
h = ROOT.TH1D("h", "h", 100, -10, 10)
h.Fill(5)
assert h.kind == "COUNT"

def test_histogram_kind_with_weights(self):
h_weighted = ROOT.TH1D("h_weighted", "h_weighted", 100, -10, 10)
h_weighted.Fill(5, 2.0)
assert h_weighted.kind == "COUNT"

def test_profile_histogram_kind(self):
h_profile = ROOT.TProfile("h_profile", "h_profile", 100, -10, 10)
h_profile.Fill(5, 3.0)
assert h_profile.kind == "MEAN"


if __name__ == "__main__":
raise SystemExit(pytest.main(args=[__file__]))
Loading