Skip to content

Migrate Figure.inset tests to use dvc #1163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_inset_aliases.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: f6ddb4129474219bfa30154614a189a5
size: 31937
path: test_inset_aliases.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_inset_context_manager.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: c06c3d8cbeb5b9b7ae977870b4c825d9
size: 13322
path: test_inset_context_manager.png
39 changes: 14 additions & 25 deletions pygmt/tests/test_inset.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,31 @@
"""
Tests for the inset function.
"""
import pytest
from pygmt import Figure
from pygmt.helpers.testing import check_figures_equal


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_inset_aliases():
"""
Test the aliases for the inset function.
"""
fig_ref, fig_test = Figure(), Figure()
fig_ref.basemap(R="MG+r2", B="afg")
with fig_ref.inset(D="jTL+w3.5c+o0.2c", M=0, F="+pgreen"):
fig_ref.basemap(R="g", J="G47/-20/4c", B="afg")
fig = Figure()
fig.basemap(region="MG+r2", frame="afg")
with fig.inset(position="jTL+w3.5c+o0.2c", margin=0, box="+pgreen"):
fig.basemap(region="g", projection="G47/-20/4c", frame="afg")
return fig

fig_test.basemap(region="MG+r2", frame="afg")
with fig_test.inset(position="jTL+w3.5c+o0.2c", margin=0, box="+pgreen"):
fig_test.basemap(region="g", projection="G47/-20/4c", frame="afg")
return fig_ref, fig_test


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_inset_context_manager():
"""
Test that the inset context manager works and, once closed, plotting
elements are added to the larger figure.
"""
fig_ref, fig_test = Figure(), Figure()

fig_ref.basemap(region=[-74, -69.5, 41, 43], projection="M9c", frame=True)
fig_ref.basemap(rose="jTR+w3c") # Pass rose argument with basemap before the inset
with fig_ref.inset(position="jBL+w3c+o0.2c", margin=0, box="+pblack"):
fig_ref.basemap(region=[-80, -65, 35, 50], projection="M3c", frame="afg")

fig_test.basemap(region=[-74, -69.5, 41, 43], projection="M9c", frame=True)
with fig_test.inset(position="jBL+w3c+o0.2c", margin=0, box="+pblack"):
fig_test.basemap(region=[-80, -65, 35, 50], projection="M3c", frame="afg")
fig_test.basemap(rose="jTR+w3c") # Pass rose argument with basemap after the inset

return fig_ref, fig_test
fig = Figure()
fig.basemap(region=[-74, -69.5, 41, 43], projection="M9c", frame=True)
with fig.inset(position="jBL+w3c+o0.2c", margin=0, box="+pblack"):
fig.basemap(region=[-80, -65, 35, 50], projection="M3c", frame="afg")
fig.basemap(rose="jTR+w3c") # Pass rose argument with basemap after the inset
return fig