| 520 | self.assertEqual(h.at(3).value, 0) |
| 521 | |
| 522 | def test_fill_2d(self): |
| 523 | for uoflow in (False, True): |
| 524 | h = histogram(integer(-1, 2, uoflow=uoflow), |
| 525 | regular(4, -2, 2, uoflow=uoflow)) |
| 526 | h(-1, -2) |
| 527 | h(-1, -1) |
| 528 | h(0, 0) |
| 529 | h(0, 1) |
| 530 | h(1, 0) |
| 531 | h(3, -1) |
| 532 | h(0, -3) |
| 533 | with self.assertRaises(Exception): |
| 534 | h(1) |
| 535 | with self.assertRaises(Exception): |
| 536 | h(1, 2, 3) |
| 537 | |
| 538 | m = [[1, 1, 0, 0, 0, 0], |
| 539 | [0, 0, 1, 1, 0, 1], |
| 540 | [0, 0, 1, 0, 0, 0], |
| 541 | [0, 1, 0, 0, 0, 0], |
| 542 | [0, 0, 0, 0, 0, 0]] |
| 543 | for get in (lambda h, x, y: h.at(x, y), |
| 544 | lambda h, x, y: h[x, y]): |
| 545 | for i in range(-uoflow, len(h.axis(0)) + uoflow): |
| 546 | for j in range(-uoflow, len(h.axis(1)) + uoflow): |
| 547 | self.assertEqual(get(h, i, j).value, m[i][j]) |
| 548 | |
| 549 | def test_add_2d(self): |
| 550 | for uoflow in (False, True): |