Skip to content

Commit

Permalink
Migrate Figure.basemap tests to dvc (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Apr 1, 2021
1 parent 0e64122 commit ebdb353
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 57 deletions.
Binary file removed pygmt/tests/baseline/test_basemap.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 61986bbf1ea20c418cbce50456d1d4f7
size: 9281
path: test_basemap.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap_compass.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 5ecccc4123b28636b62e01f642006ae4
size: 90778
path: test_basemap_compass.png
Binary file removed pygmt/tests/baseline/test_basemap_list_region.png
Binary file not shown.
Binary file removed pygmt/tests/baseline/test_basemap_loglog.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap_loglog.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 04df0757105b810a647f545f4f7371fb
size: 28235
path: test_basemap_loglog.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap_map_scale.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: f1ff6ede343ce3d2fc42cbe9ef0ba96b
size: 40128
path: test_basemap_map_scale.png
Binary file removed pygmt/tests/baseline/test_basemap_polar.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap_polar.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 7326eb42c54c6300a634f0723664fb39
size: 33205
path: test_basemap_polar.png
Binary file removed pygmt/tests/baseline/test_basemap_power_axis.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap_power_axis.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 6d9dd0086ab8226f180c6aae5ec3e4a6
size: 31288
path: test_basemap_power_axis.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap_rose.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: ede2912205feff80db261b54ff8d5bec
size: 41421
path: test_basemap_rose.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap_winkel_tripel.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: d0d2c680e9e6e1b546566d9aa2aaf830
size: 70487
path: test_basemap_winkel_tripel.png
102 changes: 45 additions & 57 deletions pygmt/tests/test_basemap.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
"""
Tests fig.basemap.
Tests Figure.basemap.
"""
import pytest
from pygmt import Figure
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers.testing import check_figures_equal


def test_basemap_required_args():
"""
fig.basemap fails when not given required arguments.
Figure.basemap fails when not given required arguments.
"""
fig = Figure()
with pytest.raises(GMTInvalidInput):
fig.basemap(R="10/70/-3/8", J="X4i/3i")
fig.basemap(region=[10, 70, -3, 8], projection="X8c/6c")


@pytest.mark.mpl_image_compare
Expand All @@ -22,17 +21,7 @@ def test_basemap():
Create a simple basemap plot.
"""
fig = Figure()
fig.basemap(R="10/70/-3/8", J="X4i/3i", B="afg")
return fig


@pytest.mark.mpl_image_compare
def test_basemap_list_region():
"""
Create a simple basemap plot passing the region as a list.
"""
fig = Figure()
fig.basemap(R=[-20, 50, 200, 500], J="X3i/3i", B="a")
fig.basemap(region=[10, 70, -3, 8], projection="X8c/6c", frame="afg")
return fig


Expand All @@ -43,11 +32,9 @@ def test_basemap_loglog():
"""
fig = Figure()
fig.basemap(
R="1/10000/1e20/1e25",
J="X25cl/15cl",
Bx="2+lWavelength",
By="a1pf3+lPower",
B="WS",
region=[1, 10000, 1e20, 1e25],
projection="X16cl/12cl",
frame=["WS", "x2+lWavelength", "ya1pf3+lPower"],
)
return fig

Expand All @@ -59,69 +46,70 @@ def test_basemap_power_axis():
"""
fig = Figure()
fig.basemap(
R=[0, 100, 0, 5000], J="x1p0.5/-0.001", B=['x1p+l"Crustal age"', "y500+lDepth"]
region=[0, 100, 0, 5000],
projection="x1p0.5/-0.001",
frame=['x1p+l"Crustal age"', "y500+lDepth"],
)
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_basemap_polar():
"""
Create a polar basemap plot.
"""
fig_ref, fig_test = Figure(), Figure()
# Use single-character arguments for the reference image
fig_ref.basemap(R="0/360/0/1000", J="P6i", B="afg")
fig_test.basemap(region=[0, 360, 0, 1000], projection="P6i", frame="afg")

return fig_ref, fig_test
fig = Figure()
fig.basemap(region=[0, 360, 0, 1000], projection="P8c", frame="afg")
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_basemap_winkel_tripel():
"""
Create a Winkel Tripel basemap plot.
"""
fig_ref, fig_test = Figure(), Figure()
fig_ref.basemap(R="90/450/-90/90", J="R270/25c", B="afg")
fig_test.basemap(region=[90, 450, -90, 90], projection="R270/25c", frame="afg")
return fig_ref, fig_test
fig = Figure()
fig.basemap(region=[90, 450, -90, 90], projection="R270/20c", frame="afg")
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_basemap_rose():
"""
Create a map with coast and use basemap to add a rose.
Create a map with a rose.
"""
fig_ref, fig_test = Figure(), Figure()
fig_ref.coast(R="127.5/128.5/26/27", W="1/0.5p")
fig_ref.basemap(Td="jBR+w5c")
fig_test.coast(region=[127.5, 128.5, 26, 27], shorelines="1/0.5p")
fig_test.basemap(rose="jBR+w5c")
return fig_ref, fig_test
fig = Figure()
fig.basemap(
region=[127.5, 128.5, 26, 27], projection="H15c", frame=True, rose="jMC+w5c"
)
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_basemap_compass():
"""
Create a map with coast and use basemap to add a compass.
Create a map with a compass.
"""
fig_ref, fig_test = Figure(), Figure()
fig_ref.coast(R="127.5/128.5/26/27", W="1/0.5p")
fig_ref.basemap(Tm="jBR+w5c+d11.5")
fig_test.coast(region=[127.5, 128.5, 26, 27], shorelines="1/0.5p")
fig_test.basemap(compass="jBR+w5c+d11.5")
return fig_ref, fig_test
fig = Figure()
fig.basemap(
region=[127.5, 128.5, 26, 27],
projection="H15c",
frame=True,
compass="jMC+w5c+d11.5",
)
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_basemap_map_scale():
"""
Create a map with coast and use basemap to add a map scale.
Create a map with a map scale.
"""
fig_ref, fig_test = Figure(), Figure()
fig_ref.coast(R="127.5/128.5/26/27", W="1/0.5p")
fig_ref.basemap(L="jMB+c1+w10k+l+f")
fig_test.coast(region=[127.5, 128.5, 26, 27], shorelines="1/0.5p")
fig_test.basemap(map_scale="jMB+c1+w10k+f+l")
return fig_ref, fig_test
fig = Figure()
fig.basemap(
region=[127.5, 128.5, 26, 27],
projection="H15c",
frame=True,
map_scale="jMC+c26.5+w10k+f+l",
)
return fig

0 comments on commit ebdb353

Please sign in to comment.