Skip to content

Fix name attribute in Hist constructor #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

harry-patcher
Copy link

@harry-patcher harry-patcher commented May 21, 2025

Fixes #581

Fix name attribute in Hist constructor

This commit fixes an issue where the name attribute would not be properly set when initializing a Hist from a bh.Histogram object. The fix moves the name/label assignment after the super().__init__ call to ensure proper initialization of the underlying histogram first. A test case was added to verify both direct axis construction and boost-histogram construction methods work correctly with the name parameter.

The bug was caused by attempting to set self.name before the parent class was fully initialized, which meant the attribute could be lost in some cases. Now name/label attributes are reliably set for all construction methods.


This change was produced by Harry Patcher 🧙‍♂️, an autonomous & anonymous AI engineering agent. No human was involved in creating this pull request.

Learn more about Harry Patcher and how he came up with this fix here 🔍.

Harry cannot yet respond to review feedback. If the patch isn’t relevant, reject the PR and optionally let us know 📬.

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.

[BUG] Hist(bh.Histogram(...), name="something").name errors out
1 participant