Skip to content

Commit

Permalink
added test for boost histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
kreczko committed Jul 18, 2019
1 parent b9bbcba commit b5732c7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/collections/test_boost_histogram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# import aghast
import awkward
import boost.histogram as bh
import numpy as np


def test_fill():
pileup_bins = [0, 10, 15, 20, 30, 999]
jet_pt_bins = [35, 90, 120]
hist = bh.histogram(
bh.axis.variable(pileup_bins),
bh.axis.variable(jet_pt_bins, bh.storage.weight()),
)

ets = awkward.fromiter([
np.random.poisson(30, 5),
np.random.poisson(30, 2),
np.random.poisson(30, 3),
])
repeat = ets.stops - ets.starts

weights = np.ones(len(ets))
weights = np.repeat(weights, repeat, axis=0)
pileup = np.random.poisson(50, len(ets))
pileup = np.repeat(pileup, repeat, axis=0)
# expand pileup to size ets
assert len(pileup) == len(ets.content)
# hist.fill(pileup, ets.content, bh.weight(weights))
hist(pileup, ets.content)

0 comments on commit b5732c7

Please sign in to comment.