Skip to content
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

Migrate pygmt.config tests to dvc #1165

Merged
merged 2 commits into from
Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Binary file removed pygmt/tests/baseline/test_config.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_config.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 7ce85985adb3858a2f8abc78e6f2826b
size: 52132
path: test_config.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_config_font_annot.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: e1a3887151ea389de97f177c19488c5e
size: 80854
path: test_config_font_annot.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_config_font_one.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: b011328f9e88799e3af073da4f2b3835
size: 97085
path: test_config_font_one.png
Binary file removed pygmt/tests/baseline/test_config_format_time_map.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_config_format_time_map.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 3d1d843c5150f2f775fdb9382284fa31
size: 10906
path: test_config_format_time_map.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_config_map_annot_offset.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 40a89f9014ac054f5f196ace06a00361
size: 9389
path: test_config_map_annot_offset.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_config_map_grid_cross_size.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: cedcf979e9d25129babae0fbeeeecfbc
size: 17539
path: test_config_map_grid_cross_size.png
Binary file removed pygmt/tests/baseline/test_config_map_grid_pen.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_config_map_grid_pen.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 04de12d91ce2f48ad0b09061077f9780
size: 17179
path: test_config_map_grid_pen.png
Binary file removed pygmt/tests/baseline/test_config_map_tick_length.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_config_map_tick_length.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: d97081684520b6a91221d25f71942cc9
size: 16855
path: test_config_map_tick_length.png
Binary file removed pygmt/tests/baseline/test_config_map_tick_pen.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_config_map_tick_pen.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 95a1755035175e331efc7508d9e8e3eb
size: 17321
path: test_config_map_tick_pen.png
83 changes: 30 additions & 53 deletions pygmt/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""
Tests for gmt config.
Tests for pygmt.config.
"""
import pytest
from pygmt import Figure, config
from pygmt.helpers.testing import check_figures_equal


@pytest.mark.mpl_image_compare
Expand All @@ -23,75 +22,53 @@ def test_config():
region="0/10/0/10",
projection="X10c/10c",
frame=['xaf+l"red label"', "yaf", '+t"red annotation"'],
X="15c",
xshift="15c",
)

fig.basemap(
region="0/10/0/10",
projection="X10c/10c",
frame=["af", '+t"Blue Annotation"'],
X="15c",
xshift="15c",
)
# Revert to default settings in current figure
config(FONT_ANNOT_PRIMARY="black")
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_config_font_one():
"""
Test that setting `FONT` config changes all `FONT_*` settings except
`FONT_LOGO`.
Test that setting FONT config changes all FONT_* settings except FONT_LOGO.

Specifically, this test only checks that `FONT_ANNOT_PRIMARY`,
`FONT_ANNOT_SECONDARY`, `FONT_LABEL`, and `FONT_TITLE` are modified.
Specifically, this test only checks that FONT_ANNOT_PRIMARY,
FONT_ANNOT_SECONDARY, FONT_LABEL, and FONT_TITLE are modified.
"""
fig_ref = Figure()
with config(
FONT_ANNOT_PRIMARY="8p,red",
FONT_ANNOT_SECONDARY="8p,red",
FONT_LABEL="8p,red",
FONT_TITLE="8p,red",
):
fig_ref.basemap(R="0/9/0/9", J="C3/3/9c", Tm="jTL+w4c+d4.5+l")
fig_ref.basemap(Tm="jBR+w5c+d-4.5+l")

fig_test = Figure()
fig = Figure()
with config(FONT="8p,red"):
fig_test.basemap(
region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5+l"
)
fig_test.basemap(compass="jBR+w5c+d-4.5+l")

return fig_ref, fig_test
fig.basemap(region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5+l")
fig.basemap(compass="jBR+w5c+d-4.5+l")
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_config_font_annot():
"""
Test that setting `FONT_ANNOT` config changes both `FONT_ANNOT_PRIMARY` and
`FONT_ANNOT_SECONDARY`.
Test that setting FONT_ANNOT config changes both FONT_ANNOT_PRIMARY and
FONT_ANNOT_SECONDARY.
"""
fig_ref = Figure()
with config(FONT_ANNOT_PRIMARY="6p,red", FONT_ANNOT_SECONDARY="6p,red"):
fig_ref.basemap(R="0/9/0/9", J="C3/3/9c", Tm="jTL+w4c+d4.5")
fig_ref.basemap(compass="jBR+w5c+d-4.5")

fig_test = Figure()
fig = Figure()
with config(FONT_ANNOT="6p,red"):
fig_test.basemap(
region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5"
)
fig_test.basemap(compass="jBR+w5c+d-4.5")

return fig_ref, fig_test
fig.basemap(region=[0, 9, 0, 9], projection="C3/3/9c", compass="jTL+w4c+d4.5")
fig.basemap(compass="jBR+w5c+d-4.5")
return fig


@pytest.mark.mpl_image_compare
def test_config_format_time_map():
"""
Test that setting `FORMAT_TIME_MAP` config changes both
`FORMAT_TIME_PRIMARY_MAP` and `FORMAT_TIME_SECONDARY_MAP`.
Test that setting FORMAT_TIME_MAP config changes both
FORMAT_TIME_PRIMARY_MAP and FORMAT_TIME_SECONDARY_MAP.
"""
fig = Figure()
with config(FORMAT_TIME_MAP="abbreviation"):
Expand All @@ -107,8 +84,8 @@ def test_config_format_time_map():
@pytest.mark.mpl_image_compare
def test_config_map_annot_offset():
"""
Test that setting `MAP_ANNOT_OFFSET` config changes both
`MAP_ANNOT_OFFSET_PRIMARY` and `MAP_ANNOT_OFFSET_SECONDARY`.
Test that setting MAP_ANNOT_OFFSET config changes both
MAP_ANNOT_OFFSET_PRIMARY and MAP_ANNOT_OFFSET_SECONDARY.
"""
fig = Figure()
with config(MAP_ANNOT_OFFSET="15p"):
Expand All @@ -124,8 +101,8 @@ def test_config_map_annot_offset():
@pytest.mark.mpl_image_compare
def test_config_map_grid_cross_size():
"""
Test that setting `MAP_GRID_CROSS_SIZE` config changes both
`MAP_GRID_CROSS_SIZE_PRIMARY` and `MAP_GRID_CROSS_SIZE_SECONDARY`.
Test that setting MAP_GRID_CROSS_SIZE config changes both
MAP_GRID_CROSS_SIZE_PRIMARY and MAP_GRID_CROSS_SIZE_SECONDARY.
"""
fig = Figure()
with config(MAP_GRID_CROSS_SIZE="3p"):
Expand All @@ -142,8 +119,8 @@ def test_config_map_grid_cross_size():
@pytest.mark.mpl_image_compare
def test_config_map_grid_pen():
"""
Test that setting `MAP_GRID_PEN` config changes both `MAP_GRID_PEN_PRIMARY`
and `MAP_GRID_PEN_SECONDARY`.
Test that setting MAP_GRID_PEN config changes both MAP_GRID_PEN_PRIMARY and
MAP_GRID_PEN_SECONDARY.
"""
fig = Figure()
with config(MAP_GRID_PEN="thick,red"):
Expand All @@ -160,8 +137,8 @@ def test_config_map_grid_pen():
@pytest.mark.mpl_image_compare
def test_config_map_tick_length():
"""
Test that setting `MAP_TICK_LENGTH` config changes both
`MAP_TICK_LENGTH_PRIMARY` and `MAP_TICK_LENGTH_SECONDARY`.
Test that setting MAP_TICK_LENGTH config changes both
MAP_TICK_LENGTH_PRIMARY and MAP_TICK_LENGTH_SECONDARY.
"""
fig = Figure()
with config(MAP_TICK_LENGTH="5p"):
Expand All @@ -178,8 +155,8 @@ def test_config_map_tick_length():
@pytest.mark.mpl_image_compare
def test_config_map_tick_pen():
"""
Test that setting `MAP_TICK_PEN` config changes both `MAP_TICK_PEN_PRIMARY`
and `MAP_TICK_PEN_SECONDARY`.
Test that setting MAP_TICK_PEN config changes both MAP_TICK_PEN_PRIMARY and
MAP_TICK_PEN_SECONDARY.
"""
fig = Figure()
with config(MAP_TICK_PEN="thick,red"):
Expand Down