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

[BUG] Error message for Mean storage different than expected #537

Closed
matthewfeickert opened this issue Sep 13, 2023 · 0 comments · Fixed by #538
Closed

[BUG] Error message for Mean storage different than expected #537

matthewfeickert opened this issue Sep 13, 2023 · 0 comments · Fixed by #538
Assignees

Comments

@matthewfeickert
Copy link
Member

matthewfeickert commented Sep 13, 2023

Describe the bug

In informal chat on the IRIS-HEP Slack with @alexander-held and myself @henryiii indicated that he thought the error for incorrectly using the Mean storage should be different.

If you update boost-histogram & Hist, that error should be better. There’s a chance that’s not better yet.

Steps to reproduce

$ python -m pip install --upgrade 'hist==2.7.2' 'boost-histogram==1.4.0'
# issue_537.py
from hist import Hist

categorical_hist = Hist.new.StrCat(["a", "b"], name="meas").Mean()
categorical_hist.fill([3, 4, 5], meas="a")
$ python issue_537.py
Traceback (most recent call last):
  File "/home/feickert/Code/debug/hist-categorical-axes-fill/issue_537.py", line 4, in <module>
    categorical_hist.fill([3, 4, 5], meas="a")
  File "/home/feickert/.pyenv/versions/hist-categorical-axes-fill/lib/python3.11/site-packages/hist/basehist.py", line 240, in fill
    raise TypeError(
TypeError: All axes must be accounted for in fill, you may have used a disallowed name in the axes

For the sake of completness, the API error that @alexander-held and I were making is that we should have done

from hist import Hist

categorical_hist = Hist.new.StrCat(["a", "b"], name="meas").Mean()
sample = [3, 4, 5]
categorical_hist.fill(sample=sample, meas=["a"] * len(sample))
henryiii added a commit that referenced this issue Sep 14, 2023
Fixes #537.

Also makes the tests pass when using boost-histogram < 1.4.

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
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 a pull request may close this issue.

2 participants