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

Function test_deepcopy

lib/matplotlib/tests/test_figure.py:1688–1710  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1686
1687
1688def test_deepcopy():
1689 fig1, ax = plt.subplots()
1690 ax.plot([0, 1], [2, 3])
1691 ax.set_yscale('log')
1692
1693 fig2 = copy.deepcopy(fig1)
1694
1695 # Make sure it is a new object
1696 assert fig2.axes[0] is not ax
1697 # And that the axis scale got propagated
1698 assert fig2.axes[0].get_yscale() == 'log'
1699 # Update the deepcopy and check the original isn't modified
1700 fig2.axes[0].set_yscale('linear')
1701 assert ax.get_yscale() == 'log'
1702
1703 # And test the limits of the axes don't get propagated
1704 ax.set_xlim(1e-1, 1e2)
1705 # Draw these to make sure limits are updated
1706 fig1.draw_without_rendering()
1707 fig2.draw_without_rendering()
1708
1709 assert ax.get_xlim() == (1e-1, 1e2)
1710 assert fig2.axes[0].get_xlim() == (0, 1)
1711
1712
1713def test_unpickle_with_device_pixel_ratio():

Callers

nothing calls this directly

Calls 7

deepcopyMethod · 0.80
subplotsMethod · 0.45
plotMethod · 0.45
set_yscaleMethod · 0.45
set_xlimMethod · 0.45
get_xlimMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…