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 when sorting IntCat axis if values >1e8 #497

Open
lfarinaa opened this issue May 16, 2023 · 0 comments
Open

[BUG] Error when sorting IntCat axis if values >1e8 #497

lfarinaa opened this issue May 16, 2023 · 0 comments

Comments

@lfarinaa
Copy link

lfarinaa commented May 16, 2023

hist.sort() calls axis._ax.index(), and produces an error if the IntCat values are too high.

Example:

import numpy as np
from hist import Hist  # version 2.6.3

hTest = (
    Hist.new.IntCat(
        np.arange(10_000_000, 10_000_200, 1), name="pdgCode", label="pdgCode"
    )
    .Weight()
    .fill(np.arange(10_000_000, 10_000_200, 1))
)
hTest.sort(0)  # works

hTest = (
    Hist.new.IntCat(
        np.arange(100_000_000, 100_000_200, 10), name="pdgCode", label="pdgCode"
    )
    .Weight()
    .fill(np.arange(100_000_000, 100_000_200, 10))
)
print(hTest)  # works
hTest.plot()  # works
hTest.sort(0)  # error: KeyError: '100000010 not in axis'

I would say it looks like some sort of an int>float>int problem.
It may look like a corner case, but in fact nuclei PDG codes have values in the ~1e9 range. It would be great if sorting could be supported also in this case.

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

No branches or pull requests

1 participant