root icon indicating copy to clipboard operation
root copied to clipboard

[Python][UHI] Extend TH1 equality operator to consider additional properties

Open siliataider opened this issue 6 months ago • 2 comments

This Pull request:

Changes or fixes:

The equality operator for ROOT histograms now compares the following properties:

  • Histogram type (including dimension).
  • Histogram kind.
  • Shape (number of bins per axis).
  • Bin contents array.
  • Sum-of-weights-squared array.
  • Axes properties.

Checklist:

  • [x] tested changes locally
  • [ ] updated the docs (if necessary)

This PR fixes #19038

siliataider avatar Jun 17 '25 09:06 siliataider

@guitargeek I did not add checks for properties related to the GUI. We should discuss if those are part of determining whether 2 ROOT histograms are equal or not

siliataider avatar Jun 17 '25 12:06 siliataider

Test Results

    20 files      20 suites   3d 16h 28m 52s ⏱️  3 013 tests  3 012 ✅ 0 💤 1 ❌ 58 672 runs  58 671 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit f13b675b.

:recycle: This comment has been updated with latest results.

github-actions[bot] avatar Jun 17 '25 13:06 github-actions[bot]

A discussion might be needed. I personally lean towards not considering aspects such as colours or marker type part of the equality: they are not related to the statistical properties of the histos and in any case those will not be part of the new histograms...

dpiparo avatar Jun 19 '25 09:06 dpiparo

I think we should keep this new equality operator only if there is a clear motivation from a user perspective,

While I see your point and I understand this new behaviour might lead to potential confusion for downstream users in the wild, let me stress that the pre-existing behaviour in master was simply wrong and a bug. If we decide against merging this PR, imagining that we find a way to accommodate the requirements for the UHI testing suite without using this equality operator, I will request that the equality operator is simply disabled for TH1 and derived classes, i.e. h1 == h2 should throw an exception.

vepadulano avatar Jun 23 '25 18:06 vepadulano

Yes, okay then we're on the same page here!

I will request that the equality operator is simply disabled for TH1 and derived classes, i.e. h1 == h2 should throw an exception.

I think that would mean kicking out this pythonization: https://github.com/root-project/root/blob/master/bindings/pyroot/pythonizations/src/TObjectPyz.cxx

Then we don't even need to throw an exception but it's simply not implemented.

guitargeek avatar Jun 23 '25 19:06 guitargeek

Closed in favor of #19209

siliataider avatar Jun 27 '25 09:06 siliataider