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

Function test_get_figure

lib/matplotlib/tests/test_artist.py:594–625  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

592
593
594def test_get_figure():
595 fig = plt.figure()
596 sfig1 = fig.subfigures()
597 sfig2 = sfig1.subfigures()
598 ax = sfig2.subplots()
599
600 assert fig.get_figure(root=True) is fig
601 assert fig.get_figure(root=False) is fig
602
603 assert ax.get_figure() is sfig2
604 assert ax.get_figure(root=False) is sfig2
605 assert ax.get_figure(root=True) is fig
606
607 # SubFigure.get_figure has separate implementation but should give consistent
608 # results to other artists.
609 assert sfig2.get_figure(root=False) is sfig1
610 assert sfig2.get_figure(root=True) is fig
611 # Currently different results by default.
612 with pytest.warns(mpl.MatplotlibDeprecationWarning):
613 assert sfig2.get_figure() is fig
614 # No deprecation warning if root and parent figure are the same.
615 assert sfig1.get_figure() is fig
616
617 # An artist not yet attached to anything has no figure.
618 ln = mlines.Line2D([], [])
619 assert ln.get_figure(root=True) is None
620 assert ln.get_figure(root=False) is None
621
622 # figure attribute is root for (Sub)Figures but parent for other artists.
623 assert ax.figure is sfig2
624 assert fig.figure is fig
625 assert sfig2.figure is fig

Callers

nothing calls this directly

Calls 4

figureMethod · 0.80
subfiguresMethod · 0.80
subplotsMethod · 0.45
get_figureMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…