Skip to content

Commit c39ac4d

Browse files
Migrate makecpt tests to use dvc (#1168)
Co-authored-by: Wei Ji <[email protected]>
1 parent 155ad1d commit c39ac4d

20 files changed

+60
-71
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 3452d1c57e68d0ff7a326a6fa35cbf5d
3+
size: 4079
4+
path: test_makecpt_categorical.png
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 9a18c81caa92725aa9de5c2dd7d74e46
3+
size: 75856
4+
path: test_makecpt_continuous.png
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 479dbbd853e31354d825e0e23e123920
3+
size: 3925
4+
path: test_makecpt_cyclic.png
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 690415b96990c3b1d1388bf263e40a0d
3+
size: 150867
4+
path: test_makecpt_plot_grid.png
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: aea39948ca2ea6924618a0e09b0020b3
3+
size: 118302
4+
path: test_makecpt_plot_grid_scaled_with_series.png
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: b28ff0dad316d0b6a860b8af7e402a56
3+
size: 26601
4+
path: test_makecpt_plot_points.png
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 6a5ca01aebcc23b00dc884fcd9c927d8
3+
size: 141567
4+
path: test_makecpt_reverse_color_and_zsign.png
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 5ad9b6aab72e45be8a1adc20f9e1c0e9
3+
size: 71377
4+
path: test_makecpt_reverse_color_only.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.
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 26f3d0d95a68799ddd4eb8a130bc1445
3+
size: 97790
4+
path: test_makecpt_truncated_zlow_zhigh.png

pygmt/tests/test_makecpt.py

Lines changed: 24 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from pygmt.datasets import load_earth_relief
1010
from pygmt.exceptions import GMTInvalidInput
1111
from pygmt.helpers import GMTTempFile
12-
from pygmt.helpers.testing import check_figures_equal
1312

1413
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
1514
POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt")
@@ -40,7 +39,7 @@ def fixture_grid():
4039

4140

4241
@pytest.mark.mpl_image_compare
43-
def test_makecpt_to_plot_points(points, region):
42+
def test_makecpt_plot_points(points, region):
4443
"""
4544
Use static color palette table to change color of points.
4645
"""
@@ -58,34 +57,29 @@ def test_makecpt_to_plot_points(points, region):
5857

5958

6059
@pytest.mark.mpl_image_compare
61-
def test_makecpt_to_plot_grid(grid):
60+
def test_makecpt_plot_grid(grid):
6261
"""
6362
Use static color palette table to change color of grid.
6463
"""
6564
fig = Figure()
6665
makecpt(cmap="relief")
67-
fig.grdimage(grid, projection="W0/6i")
66+
fig.grdimage(grid, projection="W0/10c")
6867
return fig
6968

7069

71-
@check_figures_equal()
72-
def test_makecpt_to_plot_grid_scaled_with_series(grid):
70+
@pytest.mark.mpl_image_compare
71+
def test_makecpt_plot_grid_scaled_with_series(grid):
7372
"""
7473
Use static color palette table scaled to a min/max series to change color
7574
of grid.
7675
"""
77-
# Use single-character arguments for the reference image
78-
fig_ref = Figure()
79-
makecpt(C="oleron", T="-4500/4500")
80-
fig_ref.grdimage(grid, J="W0/6i")
81-
82-
fig_test = Figure()
83-
makecpt(cmap="oleron", series="-4500/4500")
84-
fig_test.grdimage(grid, projection="W0/6i")
85-
return fig_ref, fig_test
76+
fig = Figure()
77+
makecpt(cmap="oleron", series=[-4500, 4500])
78+
fig.grdimage(grid, projection="W0/10c")
79+
return fig
8680

8781

88-
def test_makecpt_output_to_cpt_file():
82+
def test_makecpt_output_cpt_file():
8983
"""
9084
Save the generated static color palette table to a .cpt file.
9185
"""
@@ -111,35 +105,13 @@ def test_makecpt_invalid_output():
111105

112106

113107
@pytest.mark.mpl_image_compare
114-
def test_makecpt_truncated_to_zlow_zhigh(grid):
108+
def test_makecpt_truncated_zlow_zhigh(grid):
115109
"""
116110
Use static color palette table that is truncated to z-low and z-high.
117111
"""
118112
fig = Figure()
119113
makecpt(cmap="rainbow", truncate=[0.15, 0.85], series=[-4500, 4500])
120-
fig.grdimage(grid, projection="W0/6i")
121-
return fig
122-
123-
124-
@pytest.mark.mpl_image_compare
125-
def test_makecpt_truncated_at_zlow_only(grid):
126-
"""
127-
Use static color palette table that is truncated at z-low only.
128-
"""
129-
fig = Figure()
130-
makecpt(cmap="rainbow", truncate=[0.5, None], series=[-4500, 4500])
131-
fig.grdimage(grid, projection="W0/6i")
132-
return fig
133-
134-
135-
@pytest.mark.mpl_image_compare
136-
def test_makecpt_truncated_at_zhigh_only(grid):
137-
"""
138-
Use static color palette table that is truncated at z-high only.
139-
"""
140-
fig = Figure()
141-
makecpt(cmap="rainbow", truncate=[None, 0.5], series=[-4500, 4500])
142-
fig.grdimage(grid, projection="W0/6i")
114+
fig.grdimage(grid, projection="W0/10c")
143115
return fig
144116

145117

@@ -150,18 +122,7 @@ def test_makecpt_reverse_color_only(grid):
150122
"""
151123
fig = Figure()
152124
makecpt(cmap="earth", reverse=True)
153-
fig.grdimage(grid, projection="W0/6i")
154-
return fig
155-
156-
157-
@pytest.mark.mpl_image_compare
158-
def test_makecpt_reverse_zsign_only(grid):
159-
"""
160-
Use static color palette table with its z-value sign reversed.
161-
"""
162-
fig = Figure()
163-
makecpt(cmap="earth", reverse="z")
164-
fig.grdimage(grid, projection="W0/6i")
125+
fig.grdimage(grid, projection="W0/10c")
165126
return fig
166127

167128

@@ -173,7 +134,7 @@ def test_makecpt_reverse_color_and_zsign(grid):
173134
"""
174135
fig = Figure()
175136
makecpt(cmap="earth", reverse="cz")
176-
fig.grdimage(grid, projection="W0/6i")
137+
fig.grdimage(grid, projection="W0/10c")
177138
return fig
178139

179140

@@ -184,39 +145,31 @@ def test_makecpt_continuous(grid):
184145
scaled from -4500 to 4500m.
185146
"""
186147
fig = Figure()
187-
makecpt(cmap="blue,white", continuous=True, series="-4500,4500")
188-
fig.grdimage(grid, projection="W0/6i")
148+
makecpt(cmap="blue,white", continuous=True, series=[-4500, 4500])
149+
fig.grdimage(grid, projection="W0/10c")
189150
return fig
190151

191152

192-
@check_figures_equal()
153+
@pytest.mark.mpl_image_compare
193154
def test_makecpt_categorical(region):
194155
"""
195156
Use static color palette table that is categorical.
196157
"""
197-
fig_ref = Figure()
198-
makecpt(C="categorical", W="")
199-
fig_ref.colorbar(cmap=True, region=region, frame=True, position="JBC")
200-
201-
fig_test = Figure()
158+
fig = Figure()
202159
makecpt(cmap="categorical", categorical=True)
203-
fig_test.colorbar(cmap=True, region=region, frame=True, position="JBC")
204-
return fig_ref, fig_test
160+
fig.colorbar(cmap=True, region=region, frame=True, position="JBC")
161+
return fig
205162

206163

207-
@check_figures_equal()
164+
@pytest.mark.mpl_image_compare
208165
def test_makecpt_cyclic(region):
209166
"""
210167
Use static color palette table that is cyclic.
211168
"""
212-
fig_ref = Figure()
213-
makecpt(C="cork", W="w")
214-
fig_ref.colorbar(cmap=True, region=region, frame=True, position="JBC")
215-
216-
fig_test = Figure()
169+
fig = Figure()
217170
makecpt(cmap="cork", cyclic=True)
218-
fig_test.colorbar(cmap=True, region=region, frame=True, position="JBC")
219-
return fig_ref, fig_test
171+
fig.colorbar(cmap=True, region=region, frame=True, position="JBC")
172+
return fig
220173

221174

222175
def test_makecpt_categorical_and_cyclic():

0 commit comments

Comments
 (0)