From 62fdc1f4d61d29269b8a468057d75c87f59cb320 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 16 Mar 2021 19:25:34 -0400 Subject: [PATCH] fix: variances was missing sqrt (#150) --- docs/changelog.rst | 3 +++ src/hist/plot.py | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index c85c5fcf..1d08bece 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,9 @@ Changelog Version 2.2.1 -------------------- +* Fix bug with `plot_pull` missing a sqrt. + `#150 `_ + * Fix static typing with ellipses. `#145 `_ diff --git a/src/hist/plot.py b/src/hist/plot.py index ad8045ef..560f3d80 100644 --- a/src/hist/plot.py +++ b/src/hist/plot.py @@ -170,7 +170,12 @@ def plot_pull( # Computation and Fit values = self.values() - yerr = self.variances() + variances = self.variances() + if variances is None: + raise RuntimeError( + "Cannot compute from a variance-less histogram, try a Weight storage" + ) + yerr = np.sqrt(variances) # Compute fit values: using func as fit model popt, pcov = curve_fit(f=func, xdata=self.axes[0].centers, ydata=values)