def testBinWithSum(self): one = Bin(5, -3.0, 7.0, named("xaxis", lambda x: x), Sum(named("yaxis", lambda x: 10.0)), Sum(lambda x: 10.0), Sum(lambda x: 10.0), Sum(lambda x: 10.0)) for _ in self.simple: one.fill(_) self.assertEqual(list(map(lambda _: _.sum, one.values)), [30.0, 20.0, 20.0, 10.0, 0.0]) self.assertEqual(one.underflow.sum, 10.0) self.assertEqual(one.overflow.sum, 10.0) self.assertEqual(one.nanflow.sum, 0.0) two = Select( lambda x: x.bool, Bin(5, -3.0, 7.0, lambda x: x.double, Sum(lambda x: 10.0), Sum(lambda x: 10.0), Sum(lambda x: 10.0), Sum(lambda x: 10.0))) for _ in self.struct: two.fill(_) self.assertEqual(list(map(lambda _: _.sum, two.cut.values)), [20.0, 10.0, 10.0, 10.0, 0.0]) self.assertEqual(two.cut.underflow.sum, 0.0) self.assertEqual(two.cut.overflow.sum, 0.0) self.assertEqual(two.cut.nanflow.sum, 0.0) self.checkScaling(one) self.checkScaling(one.toImmutable()) self.checkJson(one) self.checkPickle(one) self.checkName(one) self.checkScaling(two) self.checkScaling(two.toImmutable()) self.checkJson(two) self.checkPickle(two) self.checkName(two)
def testBin(self): one = Bin(5, -3.0, 7.0, named("xaxis", lambda x: x)) for _ in self.simple: one.fill(_) self.assertEqual(list(map(lambda _: _.entries, one.values)), [3.0, 2.0, 2.0, 1.0, 0.0]) self.assertEqual(one.underflow.entries, 1.0) self.assertEqual(one.overflow.entries, 1.0) self.assertEqual(one.nanflow.entries, 0.0) two = Select(lambda x: x.bool, Bin(5, -3.0, 7.0, lambda x: x.double)) for _ in self.struct: two.fill(_) self.assertEqual(list(map(lambda _: _.entries, two.cut.values)), [2.0, 1.0, 1.0, 1.0, 0.0]) self.assertEqual(two.cut.underflow.entries, 0.0) self.assertEqual(two.cut.overflow.entries, 0.0) self.assertEqual(two.cut.nanflow.entries, 0.0) self.checkScaling(one) self.checkScaling(one.toImmutable()) self.checkJson(one) self.checkPickle(one) self.checkName(one) self.checkScaling(two) self.checkScaling(two.toImmutable()) self.checkJson(two) self.checkPickle(two) self.checkName(two)