[[“one”, “two”], [“three”]], then there’s not a good way to do that, but it’s tricky to write as well; what is the name for the merged bin? Since we depend on Python 3.6+ now, I guess an (ordered) dict could be used; keys would be new bin names, and the values would be collections of bins to merge. If we had
pick, I think it would be easier, you could select each iteration then merge.
coffea/histbecause the current workaround is not trivial
h[hist.tag.underflow, 1]a value gets returned as expected. If I try to make a projection like
h[hist.tag.underflow, ...]I am hit with
ValueError: bins > 0 required
import hist import numpy as np s = hist.tag.Slicer() w = 1e-2 # e.g. a cross section for a process x = np.random.normal(loc=0.4, scale=0.4, size=1000) y = np.random.normal(loc=0.6, scale=0.4, size=1000) h = hist.Hist( hist.axis.Regular(3, 0, 1, name="x", label="axis"), hist.axis.Regular(3, 0, 1, name="y", label="axis"), hist.storage.Weight() ) h.fill(x=x, y=y, weight=w) h[hist.tag.underflow, ...]
coffeaif I understand that correctly) and then save all at once?
In this talk, https://indico.cern.ch/event/1028381/#6-pythonic-data-science, I pointed out that this is an area that needs improvement: serialization of boost-histograms and interoperability with ROOT. One avenue is to use ROOT histograms as the serialization format, which takes advantage of the predominance of that format, but would lose some of the boost-histogram features, like mixed categorical/continuous axes. Uproot writing should do those conversions in either case.
Beyond that, there ought to be a lossless way to save and load boost-histograms.
This is likely a very easy question, but I haven't found the answer. What's a quick way to
h.plot(...) with a logarithmic y-axis? I've tried
I could follow the example given in scikit-hep/hist#198 and extract the
ax object out of the output, but I'm writing a tutorial and I want to show how easy this is. (It's for the Uproot tutorial, but I'm trying to include related libraries.)
Hist.plotis sending some properties downstream (i.e. nothing to look up: they're defined by Matplotlib), in the StepPatch object it turns out.
axis definitely good. That's saved me a few times (in Pandas).
matplotlib.pyplot as pltis, duplicating the interface is not the way. For faster access I could see 2 options 1) have a shortcut to pyplot with
.plot()returning the ax object. I think Henry is very pro returning the artists, but the tuple with the artists could quite easily contain the ax as well. Then you could do
h_obj.plot().ax.semilogy()if you really wanted a one-liner