()
| 592 | |
| 593 | |
| 594 | def 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…