Skip to content

[Python][UHI] Accept objects with _to_uhi_ in the constructor - #23408

Merged
siliataider merged 2 commits into
root-project:masterfrom
siliataider:uhi
Sep 21, 2026
Merged

siliataider merged 2 commits into
root-project:masterfrom
siliataider:uhi

Conversation

@siliataider

Copy link
Copy Markdown
Contributor

This Pull request:

Changes or fixes:

ROOT.TH1*(obj) now accepts any object with a _to_uhi_ method next to the raw UHI dict. The object is converted to its UHI dict and the rest of the code path remains unchanged.

THis feature is also provided by other UHI-comaptible libraries (see scikit-hep/hist#719 and scikit-hep/boost-histogram#1191 for example).

h_hist = hist.Hist.new.Reg(...).Double()
...

h_root_from_hist = ROOT.TH1D(h_hist)

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 16h 17m 52s ⏱️
 3 874 tests  3 873 ✅ 0 💤 1 ❌
80 065 runs  80 064 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 873f180.

♻️ This comment has been updated with latest results.

@siliataider siliataider reopened this Sep 18, 2026
@siliataider siliataider added the clean build Ask CI to do non-incremental build on PR label Sep 20, 2026
@siliataider siliataider reopened this Sep 20, 2026

@vepadulano vepadulano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given it's already possible to achieve the same by constructing an histogram with the output of from_uhi, I think this is a nice shortcut saving the user a few characters and a mental jump. Thanks!

@siliataider
siliataider merged commit 2b93253 into root-project:master Sep 21, 2026
105 of 137 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean build Ask CI to do non-incremental build on PR in:Python Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants