MCPcopy Create free account
hub / github.com/boostorg/histogram / test_operators

Method test_operators

test/python_suite_test.py:652–669  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

650 h.at(4).variance
651
652 def test_operators(self):
653 h = histogram(integer(0, 2))
654 h(0)
655 h += h
656 self.assertEqual(h.at(0).value, 2)
657 self.assertEqual(h.at(0).variance, 2)
658 self.assertEqual(h.at(1).value, 0)
659 h *= 2
660 self.assertEqual(h.at(0).value, 4)
661 self.assertEqual(h.at(0).variance, 8)
662 self.assertEqual(h.at(1).value, 0)
663 self.assertEqual((h + h).at(0).value, (2 * h).at(0).value)
664 self.assertEqual((h + h).at(0).value, (h * 2).at(0).value)
665 self.assertNotEqual((h + h).at(0).variance, (2 * h).at(0).variance)
666 self.assertNotEqual((h + h).at(0).variance, (h * 2).at(0).variance)
667 h2 = histogram(regular(2, 0, 2))
668 with self.assertRaises(ValueError):
669 h + h2
670
671 def test_reduce_to(self):
672 h = histogram(integer(0, 2), integer(1, 4))

Callers

nothing calls this directly

Calls 4

integerClass · 0.90
regularClass · 0.90
atMethod · 0.80
histogramClass · 0.50

Tested by

no test coverage detected