From c3789b0e0d351aea41e293c09518fa1f1275386b Mon Sep 17 00:00:00 2001 From: Lindsey Gray Date: Wed, 23 Dec 2020 21:55:48 -0600 Subject: [PATCH] allow weights to be single numbers like values --- coffea/hist/hist_tools.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coffea/hist/hist_tools.py b/coffea/hist/hist_tools.py index 738c43a33..1ee2ebcc0 100644 --- a/coffea/hist/hist_tools.py +++ b/coffea/hist/hist_tools.py @@ -954,6 +954,8 @@ def fill(self, **values): weight = values.pop("weight", None) if isinstance(weight, (awkward1.Array, np.ndarray)): weight = coffea.util._ensure_flat(weight) + if isinstance(weight, numbers.Number): + weight = np.atleast_1d(weight) if not all(d.name in values for d in self._axes): missing = ", ".join(d.name for d in self._axes if d.name not in values) raise ValueError("Not all axes specified for %r. Missing: %s" % (self, missing))