| 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)) |