-
Notifications
You must be signed in to change notification settings - Fork 66
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
fix: array copy and logic for obtaining variances and values #488
Conversation
for more information, see https://pre-commit.ci
Thanks! I got a bit lazy about the copies, should have fixed that :)
I think this is what's tripping up the CI.
Sounds good PS. Makes me kind of happy to see this kind of stuff caught on CI downstream |
true, I've refactored and re-arranged a bit. Also added a test without the variances, as this would fail.
yes, the advantage of a nice library that is used by many others ;) |
Looks fine from my side, mypy fails because of the over- and underflow being arrays, not floats. Feel free to adjust, I think it was like this before as well, or let me know what's the best way to go. Otherwise can be merged from my side |
Huh, so the return type for Can you check if this still fine in zfit? I'll merge it then. We could also do |
the type returned was actually a numpy.float64, but now it's an array with shape (), afaiu. The performance should be about the same, the expensive part is anyways the copy of large array (if at all), and that happens in both cases.
yes, works, can be merged
that should also work I think, alternatively, we could also convert to floats... all works, as long as we don't use the |
Alright, let's run with this for now, see if anything comes up laters. Thanks for the PR! |
* fix: array copy and logic * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix: new logic with values and flow * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * tests: expand test to incorporate hists _without_ variance * tests: fix parametrized histplot flow variances test * ci: fix mypy --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: andrzejnovak <novak5andrzej@gmail.com>
I've noticed the new
.copy()
to avoid that the underlying array changes (such as here https://github.com/scikit-hep/mplhep/blob/master/src/mplhep/plot.py#L191).I would suggest to follow closer the array protocol, which uses the
np.copy
-> other, array-like types (like JAX, TensorFlow, PyTorch etc) may don't have thecopy
attribute but support thenp.copy
(as we've noticed in the CI).Also, the logic was possibly flawed, as a histogram also has
values
and therefore, it would take the second if, wouldn't it? Removed also the re-assignement of 0 to the flows, they were already initialized with 0.Does the new flow makes sense?