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

feat: allow wildcards in StrCat list indexing #601

Merged
merged 3 commits into from
Feb 18, 2025

Conversation

andrzejnovak
Copy link
Member

@andrzejnovak andrzejnovak commented Feb 13, 2025

For a demo hist like

import hist
import numpy as np
import string

h = hist.new.Reg(10, 0, 10).StrCat([], growth=True).Weight()
N = 100000
for cat in ["ABC", "BCD", "CDE", "DEF"]:
    h.fill(
        np.random.normal(np.random.uniform(0, 10), 1, N), cat
    )
h.plot2d()

image

This allows slicing like

h[:, "*E*"]

image

and

h[:, ["*B*", "?D?"]]

image

@andrzejnovak andrzejnovak force-pushed the wildcards branch 2 times, most recently from 5717edb to fc7c16f Compare February 13, 2025 13:47
@henryiii
Copy link
Member

Thought about it a bit to make sure it shouldn't in fact go to loc. I think leaving it as a shortcut here is fine. Just needs a test or two.

@andrzejnovak
Copy link
Member Author

@henryiii added a test. I also had to pass axis id to not look for available only for a specific axis and tweak the typing a bit

@henryiii henryiii merged commit af70f54 into scikit-hep:main Feb 18, 2025
10 checks passed
@henryiii
Copy link
Member

Thanks!

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.

2 participants