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 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_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: 9a18c81caa92725aa9de5c2dd7d74e46
size: 75856
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
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_makecpt_plot_grid.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 690415b96990c3b1d1388bf263e40a0d
size: 150867
path: test_makecpt_plot_grid.png
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: aea39948ca2ea6924618a0e09b0020b3
size: 118302
path: test_makecpt_plot_grid_scaled_with_series.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_makecpt_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_plot_points.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 6a5ca01aebcc23b00dc884fcd9c927d8
size: 141567
path: test_makecpt_reverse_color_and_zsign.png
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: 5ad9b6aab72e45be8a1adc20f9e1c0e9
size: 71377
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.
Binary file not shown.
Binary file not shown.
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: 26f3d0d95a68799ddd4eb8a130bc1445
size: 97790
path: test_makecpt_truncated_zlow_zhigh.png
95 changes: 24 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 @@ -40,7 +39,7 @@ def fixture_grid():


@pytest.mark.mpl_image_compare
def test_makecpt_to_plot_points(points, region):
def test_makecpt_plot_points(points, region):
"""
Use static color palette table to change color of points.
"""
Expand All @@ -58,34 +57,29 @@ def test_makecpt_to_plot_points(points, region):


@pytest.mark.mpl_image_compare
def test_makecpt_to_plot_grid(grid):
def test_makecpt_plot_grid(grid):
"""
Use static color palette table to change color of grid.
"""
fig = Figure()
makecpt(cmap="relief")
fig.grdimage(grid, projection="W0/6i")
fig.grdimage(grid, projection="W0/10c")
return fig


@check_figures_equal()
def test_makecpt_to_plot_grid_scaled_with_series(grid):
@pytest.mark.mpl_image_compare
def test_makecpt_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()
makecpt(cmap="oleron", series="-4500/4500")
fig_test.grdimage(grid, projection="W0/6i")
return fig_ref, fig_test
fig = Figure()
makecpt(cmap="oleron", series=[-4500, 4500])
fig.grdimage(grid, projection="W0/10c")
return fig


def test_makecpt_output_to_cpt_file():
def test_makecpt_output_cpt_file():
"""
Save the generated static color palette table to a .cpt file.
"""
Expand All @@ -111,35 +105,13 @@ def test_makecpt_invalid_output():


@pytest.mark.mpl_image_compare
def test_makecpt_truncated_to_zlow_zhigh(grid):
def test_makecpt_truncated_zlow_zhigh(grid):
"""
Use static color palette table that is truncated to z-low and z-high.
"""
fig = Figure()
makecpt(cmap="rainbow", truncate=[0.15, 0.85], series=[-4500, 4500])
fig.grdimage(grid, projection="W0/6i")
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")
fig.grdimage(grid, projection="W0/10c")
return fig


Expand All @@ -150,18 +122,7 @@ def test_makecpt_reverse_color_only(grid):
"""
fig = Figure()
makecpt(cmap="earth", reverse=True)
fig.grdimage(grid, projection="W0/6i")
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")
fig.grdimage(grid, projection="W0/10c")
return fig


Expand All @@ -173,7 +134,7 @@ def test_makecpt_reverse_color_and_zsign(grid):
"""
fig = Figure()
makecpt(cmap="earth", reverse="cz")
fig.grdimage(grid, projection="W0/6i")
fig.grdimage(grid, projection="W0/10c")
return fig


Expand All @@ -184,39 +145,31 @@ def test_makecpt_continuous(grid):
scaled from -4500 to 4500m.
"""
fig = Figure()
makecpt(cmap="blue,white", continuous=True, series="-4500,4500")
fig.grdimage(grid, projection="W0/6i")
makecpt(cmap="blue,white", continuous=True, series=[-4500, 4500])
fig.grdimage(grid, projection="W0/10c")
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