Skip to content

[Python] Use isinstance instead of repr check in RooFit.bindFunction - #23614

Merged
guitargeek merged 2 commits into
root-project:masterfrom
jmcarcell:fix-rooglobalfunc-isinstance
Oct 7, 2026
Merged

guitargeek merged 2 commits into
root-project:masterfrom
jmcarcell:fix-rooglobalfunc-isinstance

Conversation

@jmcarcell

Copy link
Copy Markdown
Contributor

This Pull request:

Changes or fixes:

The check for C++ functions in bindFunction/bindPdf was using string matching on repr(type(func)), which breaks across cppyy/cppjit versions. This PR replaces it with isinstance(func, ROOT._cppyy.types.Function), which works for both because ROOT provides a cppyy compatibility alias.

Before: if "cppjit" in repr(type(func)):
After: if isinstance(func, ROOT._cppyy.types.Function):

This matches the pattern already used elsewhere in ROOT pythonizations (e.g., _roofit/_utils.py, _rdf_pyz.py) and is the same fix applied to podio in AIDASoft/podio#1031.

The AI assistant identified this issue by comparing with the podio fix and searching for similar patterns in the ROOT codebase.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes a forward/backward compatibility issue with C++ function detection in RooFit pythonizations.

The check for C++ functions in bindFunction/bindPdf was using string
matching on repr(type(func)), which breaks across cppyy/cppjit versions.
Replace with isinstance(func, ROOT._cppyy.types.Function), which works
for both because ROOT provides a cppyy compatibility alias.

This matches the pattern already used elsewhere in ROOT pythonizations
(e.g., _roofit/_utils.py, _rdf_pyz.py) and is the same fix applied to
podio in AIDASoft/podio#1031.

Assisted-by: pi:claude-sonnet-4
@guitargeek

Copy link
Copy Markdown
Contributor

@jmcarcell There are CI build failures. You'll address them, or you want me to take over?

@jmcarcell

Copy link
Copy Markdown
Contributor Author

Having a look

@jmcarcell
jmcarcell requested a review from siliataider as a code owner October 6, 2026 15:15
@jmcarcell

Copy link
Copy Markdown
Contributor Author

Maybe consider adding me to the list of people that don't need their workflows approved manually

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Test Results

    24 files      24 suites   3d 22h 32m 25s ⏱️
 3 883 tests  3 879 ✅ 0 💤 4 ❌
83 111 runs  83 107 ✅ 0 💤 4 ❌

For more details on these failures, see this check.

Results for commit 2fcddb4.

@guitargeek

Copy link
Copy Markdown
Contributor

Maybe consider adding me to the list of people that don't need their workflows approved manually

@dpiparo, would that be possible?

@guitargeek guitargeek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thanks for this targeted fix.

@guitargeek
guitargeek merged commit 2eab082 into root-project:master Oct 7, 2026
31 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants