Skip to content

Migrate makecpt tests to use dvc #1168

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 14 commits into from
Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from 7 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_makecpt_categorical.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 3452d1c57e68d0ff7a326a6fa35cbf5d
size: 4079
path: test_makecpt_categorical.png
Binary file removed pygmt/tests/baseline/test_makecpt_continuous.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_makecpt_continuous.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 1cb047b4f98d5ab9debd9c3f9efde380
size: 82931
path: test_makecpt_continuous.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_makecpt_cyclic.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 479dbbd853e31354d825e0e23e123920
size: 3925
path: test_makecpt_cyclic.png
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_makecpt_reverse_color_only.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: e50ee94870da6bbf7997d60de3441099
size: 78186
path: test_makecpt_reverse_color_only.png
Binary file not shown.
Binary file removed pygmt/tests/baseline/test_makecpt_to_plot_grid.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_makecpt_to_plot_grid.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 945df99c79067b0d14842b8e9180094a
size: 157944
path: test_makecpt_to_plot_grid.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 909dc312f46eafc5c81708f6ea99ec0e
size: 125699
path: test_makecpt_to_plot_grid_scaled_with_series.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_makecpt_to_plot_points.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: b28ff0dad316d0b6a860b8af7e402a56
size: 26601
path: test_makecpt_to_plot_points.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 448adcd0ed64760fcd8a7565e257ce49
size: 104526
path: test_makecpt_truncated_to_zlow_zhigh.png
83 changes: 12 additions & 71 deletions pygmt/tests/test_makecpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from pygmt.datasets import load_earth_relief
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import GMTTempFile
from pygmt.helpers.testing import check_figures_equal

TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt")
Expand Down Expand Up @@ -68,21 +67,16 @@ def test_makecpt_to_plot_grid(grid):
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_makecpt_to_plot_grid_scaled_with_series(grid):
"""
Use static color palette table scaled to a min/max series to change color
of grid.
"""
# Use single-character arguments for the reference image
fig_ref = Figure()
makecpt(C="oleron", T="-4500/4500")
fig_ref.grdimage(grid, J="W0/6i")

fig_test = Figure()
fig = Figure()
makecpt(cmap="oleron", series="-4500/4500")
fig_test.grdimage(grid, projection="W0/6i")
return fig_ref, fig_test
fig.grdimage(grid, projection="W0/6i")
return fig


def test_makecpt_output_to_cpt_file():
Expand Down Expand Up @@ -121,28 +115,6 @@ def test_makecpt_truncated_to_zlow_zhigh(grid):
return fig


@pytest.mark.mpl_image_compare
def test_makecpt_truncated_at_zlow_only(grid):
"""
Use static color palette table that is truncated at z-low only.
"""
fig = Figure()
makecpt(cmap="rainbow", truncate=[0.5, None], series=[-4500, 4500])
fig.grdimage(grid, projection="W0/6i")
return fig


@pytest.mark.mpl_image_compare
def test_makecpt_truncated_at_zhigh_only(grid):
"""
Use static color palette table that is truncated at z-high only.
"""
fig = Figure()
makecpt(cmap="rainbow", truncate=[None, 0.5], series=[-4500, 4500])
fig.grdimage(grid, projection="W0/6i")
return fig


@pytest.mark.mpl_image_compare
def test_makecpt_reverse_color_only(grid):
"""
Expand All @@ -154,29 +126,6 @@ def test_makecpt_reverse_color_only(grid):
return fig


@pytest.mark.mpl_image_compare
def test_makecpt_reverse_zsign_only(grid):
"""
Use static color palette table with its z-value sign reversed.
"""
fig = Figure()
makecpt(cmap="earth", reverse="z")
fig.grdimage(grid, projection="W0/6i")
return fig


@pytest.mark.mpl_image_compare
def test_makecpt_reverse_color_and_zsign(grid):
"""
Use static color palette table with both its colors and z-value sign
reversed.
"""
fig = Figure()
makecpt(cmap="earth", reverse="cz")
fig.grdimage(grid, projection="W0/6i")
return fig


@pytest.mark.mpl_image_compare
def test_makecpt_continuous(grid):
"""
Expand All @@ -189,34 +138,26 @@ def test_makecpt_continuous(grid):
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_makecpt_categorical(region):
"""
Use static color palette table that is categorical.
"""
fig_ref = Figure()
makecpt(C="categorical", W="")
fig_ref.colorbar(cmap=True, region=region, frame=True, position="JBC")

fig_test = Figure()
fig = Figure()
makecpt(cmap="categorical", categorical=True)
fig_test.colorbar(cmap=True, region=region, frame=True, position="JBC")
return fig_ref, fig_test
fig.colorbar(cmap=True, region=region, frame=True, position="JBC")
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_makecpt_cyclic(region):
"""
Use static color palette table that is cyclic.
"""
fig_ref = Figure()
makecpt(C="cork", W="w")
fig_ref.colorbar(cmap=True, region=region, frame=True, position="JBC")

fig_test = Figure()
fig = Figure()
makecpt(cmap="cork", cyclic=True)
fig_test.colorbar(cmap=True, region=region, frame=True, position="JBC")
return fig_ref, fig_test
fig.colorbar(cmap=True, region=region, frame=True, position="JBC")
return fig


def test_makecpt_categorical_and_cyclic():
Expand Down