Skip to content
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

Support inhomogeneous uncertainties #266

Closed
GraemeWatt opened this issue Jul 22, 2024 · 1 comment · Fixed by #265
Closed

Support inhomogeneous uncertainties #266

GraemeWatt opened this issue Jul 22, 2024 · 1 comment · Fixed by #265
Labels
enhancement New feature or request

Comments

@GraemeWatt
Copy link
Member

GraemeWatt commented Jul 22, 2024

I'm currently struggling to use the hepdata_lib for cases with inhomogeneous error breakdowns across bins. For instance, I have a distribution with three bins where the first two bins have two error components 'A' and 'B' (but not 'C') and the third bin has error component 'C' (but not 'A' and 'B').

I know this is supported in principle, e.g. by just omitting the respective components in the dictionary. However, when using the library, it seems hepdata_lib/helpers.py raises a ValueError

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part.

Is there a trick?

Originally posted by @20DM in #229 (comment)

PS - just to be clear: of course I can "make it pass" by just setting the uncertainty to zero, but then all bins will have three uncertainty components, some of them zero, which is not the same as the bin not having the component in its breakdown to begin with. I think the problem is that the check for "non-zero uncertainties" only checks if there's at least one non-zero component and then adds all of them, regardless of their value. Can we make this more flexible?

Originally posted by @20DM in #229 (comment)

@GraemeWatt
Copy link
Member Author

@20DM : I've moved your comments to a new issue. Indeed, hepdata_lib was designed to be simple and some more advanced features of the HEPData YAML format are not supported (for example, percentage uncertainties, #87). Yes, setting the missing components to zero is the workaround at the moment, but I see your point that this is not the same as omitting those components. I was going to suggest adding an option to the Uncertainty class to suppress zero uncertainties, then checking for this new option when constructing the errors in make_dict, but your solution in PR #265 looks better.

@GraemeWatt GraemeWatt added the enhancement New feature or request label Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant