From 67c0e19e71a0a9d90cdcc962d55b73873701f137 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Fri, 5 Oct 2018 14:17:21 -0400 Subject: [PATCH 1/3] README: fix missing use of "r" and "phi" shorthands [ci skip] --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 964cd76..7f48da0 100644 --- a/README.rst +++ b/README.rst @@ -264,7 +264,7 @@ The `stack >> r = "sqrt(x**2 + y**2)" >>> phi = "arctan2(y, x)" - >>> hist.stack("arctan2(y, x)").area("sqrt(x**2+y**2)").to(canvas) + >>> hist.stack(phi).area(r).to(canvas) .. image:: docs/source/intro-4.png From b34b5422f844b8d4981d92bffe74c3e724c888ee Mon Sep 17 00:00:00 2001 From: Clemens Lange Date: Fri, 26 Oct 2018 18:28:08 +0200 Subject: [PATCH 2/3] add support for exporting to TH2 --- histbook/export.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/histbook/export.py b/histbook/export.py index fe38c83..0c23f32 100644 --- a/histbook/export.py +++ b/histbook/export.py @@ -288,8 +288,23 @@ def root(self, *axis, **opts): out.SetBinError(i, rooterrors[i]) elif len(binaxis) == 2: + xaxis = binaxis[0] + yaxis = binaxis[1] + if profile is None: - raise NotImplementedError("TH2") + out = ROOT.TH2D(name, title, xaxis.numbins, xaxis.low, xaxis.high, yaxis.numbins, yaxis.low, yaxis.high) + + entries = numpy.zeros((xaxis.numbins + 2, yaxis.numbins + 2), dtype=numpy.float64) + entries[(0 if xaxis.underflow else 1) : (None if xaxis.overflow else -1), (0 if yaxis.underflow else 1) : (None if yaxis.overflow else -1)] = content["count()"][: (-1 if xaxis.nanflow else None), : (-1 if yaxis.nanflow else None)] + for idx, val in numpy.ndenumerate(entries): + out.SetBinContent(idx[0], idx[1], val) + out.SetEntries(entries.sum()) + + if "err(count())" in content.dtype.names: + errors = numpy.zeros(xaxis.numbins + 2, yaxis.numbins + 2, dtype=numpy.float64) + errors[(0 if xaxis.underflow else 1) : (None if xaxis.overflow else -1), (0 if yaxis.underflow else 1) : (None if yaxis.overflow else -1)] = content["err(count())"][: (-1 if xaxis.nanflow else None), : (-1 if yaxis.nanflow else None)] + for idx, val in numpy.ndenumerate(errors): + out.SetBinError(idx[0], idx[1], val) else: raise NotImplementedError("TProfile2D") From 347899904030200549f0a017bcca9b0d4c8087f5 Mon Sep 17 00:00:00 2001 From: Jim Pivarski Date: Fri, 26 Oct 2018 13:53:36 -0500 Subject: [PATCH 3/3] Two-dimensional histogram -> PyROOT. Thanks, @clelange! --- histbook/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/histbook/version.py b/histbook/version.py index e94b27d..4377999 100644 --- a/histbook/version.py +++ b/histbook/version.py @@ -30,7 +30,7 @@ import re -__version__ = "1.2.3" +__version__ = "1.2.4" version = __version__ version_info = tuple(re.split(r"[-\.]", __version__))