|
1 | 1 | """
|
2 | 2 | Tests for the inset function.
|
3 | 3 | """
|
| 4 | +import pytest |
4 | 5 | from pygmt import Figure
|
5 |
| -from pygmt.helpers.testing import check_figures_equal |
6 | 6 |
|
7 | 7 |
|
8 |
| -@check_figures_equal() |
| 8 | +@pytest.mark.mpl_image_compare |
9 | 9 | def test_inset_aliases():
|
10 | 10 | """
|
11 | 11 | Test the aliases for the inset function.
|
12 | 12 | """
|
13 |
| - fig_ref, fig_test = Figure(), Figure() |
14 |
| - fig_ref.basemap(R="MG+r2", B="afg") |
15 |
| - with fig_ref.inset(D="jTL+w3.5c+o0.2c", M=0, F="+pgreen"): |
16 |
| - fig_ref.basemap(R="g", J="G47/-20/4c", B="afg") |
| 13 | + fig = Figure() |
| 14 | + fig.basemap(region="MG+r2", frame="afg") |
| 15 | + with fig.inset(position="jTL+w3.5c+o0.2c", margin=0, box="+pgreen"): |
| 16 | + fig.basemap(region="g", projection="G47/-20/4c", frame="afg") |
| 17 | + return fig |
17 | 18 |
|
18 |
| - fig_test.basemap(region="MG+r2", frame="afg") |
19 |
| - with fig_test.inset(position="jTL+w3.5c+o0.2c", margin=0, box="+pgreen"): |
20 |
| - fig_test.basemap(region="g", projection="G47/-20/4c", frame="afg") |
21 |
| - return fig_ref, fig_test |
22 | 19 |
|
23 |
| - |
24 |
| -@check_figures_equal() |
| 20 | +@pytest.mark.mpl_image_compare |
25 | 21 | def test_inset_context_manager():
|
26 | 22 | """
|
27 | 23 | Test that the inset context manager works and, once closed, plotting
|
28 | 24 | elements are added to the larger figure.
|
29 | 25 | """
|
30 |
| - fig_ref, fig_test = Figure(), Figure() |
31 |
| - |
32 |
| - fig_ref.basemap(region=[-74, -69.5, 41, 43], projection="M9c", frame=True) |
33 |
| - fig_ref.basemap(rose="jTR+w3c") # Pass rose argument with basemap before the inset |
34 |
| - with fig_ref.inset(position="jBL+w3c+o0.2c", margin=0, box="+pblack"): |
35 |
| - fig_ref.basemap(region=[-80, -65, 35, 50], projection="M3c", frame="afg") |
36 |
| - |
37 |
| - fig_test.basemap(region=[-74, -69.5, 41, 43], projection="M9c", frame=True) |
38 |
| - with fig_test.inset(position="jBL+w3c+o0.2c", margin=0, box="+pblack"): |
39 |
| - fig_test.basemap(region=[-80, -65, 35, 50], projection="M3c", frame="afg") |
40 |
| - fig_test.basemap(rose="jTR+w3c") # Pass rose argument with basemap after the inset |
41 |
| - |
42 |
| - return fig_ref, fig_test |
| 26 | + fig = Figure() |
| 27 | + fig.basemap(region=[-74, -69.5, 41, 43], projection="M9c", frame=True) |
| 28 | + with fig.inset(position="jBL+w3c+o0.2c", margin=0, box="+pblack"): |
| 29 | + fig.basemap(region=[-80, -65, 35, 50], projection="M3c", frame="afg") |
| 30 | + fig.basemap(rose="jTR+w3c") # Pass rose argument with basemap after the inset |
| 31 | + return fig |
0 commit comments