| 1620 | |
| 1621 | |
| 1622 | def test_norm_callback(): |
| 1623 | increment = unittest.mock.Mock(return_value=None) |
| 1624 | |
| 1625 | norm = mcolors.Normalize() |
| 1626 | norm.callbacks.connect('changed', increment) |
| 1627 | # Haven't updated anything, so call count should be 0 |
| 1628 | assert increment.call_count == 0 |
| 1629 | |
| 1630 | # Now change vmin and vmax to test callbacks |
| 1631 | norm.vmin = 1 |
| 1632 | assert increment.call_count == 1 |
| 1633 | norm.vmax = 5 |
| 1634 | assert increment.call_count == 2 |
| 1635 | # callback shouldn't be called if setting to the same value |
| 1636 | norm.vmin = 1 |
| 1637 | assert increment.call_count == 2 |
| 1638 | norm.vmax = 5 |
| 1639 | assert increment.call_count == 2 |
| 1640 | |
| 1641 | # We only want autoscale() calls to send out one update signal |
| 1642 | increment.reset_mock() |
| 1643 | norm.autoscale([0, 1, 2]) |
| 1644 | assert increment.call_count == 1 |
| 1645 | |
| 1646 | |
| 1647 | def test_scalarmappable_norm_update(): |