Open
Description
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!
Metadata
Metadata
Assignees
Labels
No labels