From 061906d34f950b016cfbea1c0d00f159c934ed0a Mon Sep 17 00:00:00 2001 From: Noel Dawe Date: Wed, 10 Jun 2015 21:30:24 +1000 Subject: [PATCH] array2hist: return the hist to allow chaining and list comprehensions --- root_numpy/_hist.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/root_numpy/_hist.py b/root_numpy/_hist.py index 782e853..ce5485f 100644 --- a/root_numpy/_hist.py +++ b/root_numpy/_hist.py @@ -219,6 +219,11 @@ def array2hist(array, hist): hist : ROOT TH1, TH2, or TH3 A ROOT histogram. + Returns + ------- + hist : ROOT TH1, TH2, or TH3 + The ROOT histogram with bin contents set from the array. + Raises ------ TypeError @@ -258,7 +263,7 @@ def array2hist(array, hist): [2, 0, 5, 6, 8], [0, 0, 6, 5, 2], [2, 2, 1, 5, 4]]) - >>> array2hist(array, hist) + >>> _ = array2hist(array, hist) >>> # dtype matches histogram type (D, F, I, S, C) >>> hist2array(hist) array([[ 9., 7., 6.], @@ -347,3 +352,4 @@ def array2hist(array, hist): ROOT.AsCObject(hist), np.ravel(np.transpose(_array))) # Set the number of entries to the number of array elements hist.SetEntries(_array.size) + return hist