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

Method test_add_2d_w

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

Source from the content-addressed store, hash-verified

578 a += b
579
580 def test_add_2d_w(self):
581 for uoflow in (False, True):
582 h = histogram(integer(-1, 2, uoflow=uoflow),
583 regular(4, -2, 2, uoflow=uoflow))
584 h(-1, -2)
585 h(-1, -1)
586 h(0, 0)
587 h(0, 1)
588 h(1, 0)
589 h(3, -1)
590 h(0, -3)
591
592 m = [[1, 1, 0, 0, 0, 0],
593 [0, 0, 1, 1, 0, 1],
594 [0, 0, 1, 0, 0, 0],
595 [0, 1, 0, 0, 0, 0],
596 [0, 0, 0, 0, 0, 0]]
597
598 h2 = histogram(integer(-1, 2, uoflow=uoflow),
599 regular(4, -2, 2, uoflow=uoflow))
600 h2(0, 0, weight=0)
601
602 h2 += h
603 h2 += h
604 h += h
605 self.assertEqual(h, h2)
606
607 for i in range(-uoflow, len(h.axis(0)) + uoflow):
608 for j in range(-uoflow, len(h.axis(1)) + uoflow):
609 self.assertEqual(h.at(i, j).value, 2 * m[i][j])
610 self.assertEqual(h.at(i, j).variance, 2 * m[i][j])
611
612 def test_repr(self):
613 h = histogram(regular(10, 0, 1), integer(0, 1))

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected