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] Scaling a slice of a histogram #736

Open
alexander-held opened this issue Apr 22, 2022 · 0 comments
Open

[FEAT] Scaling a slice of a histogram #736

alexander-held opened this issue Apr 22, 2022 · 0 comments

Comments

@alexander-held
Copy link
Member

Hi, I ran into a scenario where I wanted to scale a part of a multi-dimensional histogram:

import hist

h = hist.Hist.new.Reg(3, 0, 3).StrCat(["a", "b"], name="cat").Double()
h.fill([1,1,2], cat="a")
h.fill([0], cat="b")

h[:, "a"] *= 2

This is not currently supported:

Traceback (most recent call last):
  File "[...]/test.py", line 7, in <module>
    h[:, "a"] *= 2
  File "[...]/lib/python3.9/site-packages/hist/basehist.py", line 327, in __setitem__
    return super().__setitem__(self._index_transform(index), value)
  File "[...]/lib/python3.9/site-packages/boost_histogram/_internal/hist.py", line 924, in __setitem__
    raise TypeError("Not supported yet")
TypeError: Not supported yet

@agoose77 pointed out an alternative that works on Gitter:

h[:, "a"] = h[:, "a"].values() * 2

I opened this issue as a feature request for the syntactic sugar of the first approach. Sorry if this is already being tracked elsewhere, I was not really sure what to search for to find potentially related issues!

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