MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_norm_callback

Function test_norm_callback

lib/matplotlib/tests/test_colors.py:1622–1644  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1620
1621
1622def 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
1647def test_scalarmappable_norm_update():

Callers

nothing calls this directly

Calls 2

autoscaleMethod · 0.95
connectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…