Skip to content

Commit e37d361

Browse files
willschlitzerweiji14seisman
authored
Migrate Figure.colorbar tests to use dvc (#1143)
* remove test_colorbar_using_paper_coordinates_horizontal() * remove test_colorbar_box_with_rounded_corners() * remove test_colorbar_shading_string() * remove test_colorbar_positioned_using_justification_code() * remove test_colorbar_box_with_secondary_border() * remove test_colorbar_box_with_clearance() * remove test_colorbar_box_with_pen() * remove test_colorbar_box_with_offset_background() * update test_colorbar_shading_boolean() to use mpl_image_compare * remove test_color_shading_float and update test_colorbar_shading_list to use mpl_image_compare * remove .png files, add .dvc files * remove test_colorbar_positioned_using_normalized_coords() * remove test_colorbar_positioned_using_map_coordinates() * remove test_colorbar_using_paper_coordinates() Co-authored-by: Wei Ji <[email protected]> Co-authored-by: Dongdong Tian <[email protected]>
1 parent e96c869 commit e37d361

21 files changed

+34
-159
lines changed
-1.48 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 6b0f073c0adc00a3c93693ee22e92b6b
3+
size: 1522
4+
path: test_colorbar_box.png
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: f8971e61c1e44c95156372f39913b945
3+
size: 1454
4+
path: test_colorbar_box_with_fill.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.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 513afcc325c918500f3b3c8de86cd63c
3+
size: 1870
4+
path: test_colorbar_scaled_z_values.png
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 056c3872738c08667a816f49c676418f
3+
size: 54042
4+
path: test_colorbar_shading_boolean.png
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: e888834c32778bbcfeccaa9fd0d04b1f
3+
size: 59418
4+
path: test_colorbar_shading_list.png
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
outs:
2+
- md5: 03e10c11514fc071f6e970c6babfd6c8
3+
size: 2542
4+
path: test_colorbar_truncated_to_zlow_zhigh.png
Binary file not shown.
Binary file not shown.

pygmt/tests/test_colorbar.py

+10-159
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,6 @@
33
"""
44
import pytest
55
from pygmt import Figure
6-
from pygmt.helpers.testing import check_figures_equal
7-
8-
9-
@pytest.mark.mpl_image_compare
10-
def test_colorbar_using_paper_coordinates():
11-
"""
12-
Create colorbar positioned at 0cm,0cm with length 1cm and width 0.5cm.
13-
"""
14-
fig = Figure()
15-
fig.colorbar(cmap="rainbow", position="x0c/0c+w1c/0.5c")
16-
return fig
17-
18-
19-
@pytest.mark.mpl_image_compare
20-
def test_colorbar_using_paper_coordinates_horizontal():
21-
"""
22-
Create colorbar positioned at 0cm,0cm with length 2cm oriented
23-
horizontally.
24-
"""
25-
fig = Figure()
26-
fig.colorbar(cmap="rainbow", position="x0c/0c+w2c+h")
27-
return fig
28-
29-
30-
@pytest.mark.mpl_image_compare
31-
def test_colorbar_positioned_using_map_coordinates():
32-
"""
33-
Create colorbar positioned at longitude,latitude 3,6 with length 2cm.
34-
"""
35-
fig = Figure()
36-
fig.basemap(region=[2, 4, 6, 8], projection="t0/2c", frame=True)
37-
fig.colorbar(cmap="rainbow", position="g3/6+w2c")
38-
return fig
39-
40-
41-
@check_figures_equal()
42-
def test_colorbar_positioned_using_justification_code():
43-
"""
44-
Create colorbar at Top Center inside the map frame with length 2cm.
45-
"""
46-
fig_ref, fig_test = Figure(), Figure()
47-
# Use single-character arguments for the reference image
48-
fig_ref.basemap(R="2/4/6/8", J="t0/2c", B="")
49-
fig_ref.colorbar(C="rainbow", D="jTC+w2c")
50-
51-
fig_test.basemap(region=[2, 4, 6, 8], projection="t0/2c", frame=True)
52-
fig_test.colorbar(cmap="rainbow", position="jTC+w2c")
53-
return fig_ref, fig_test
54-
55-
56-
@pytest.mark.mpl_image_compare
57-
def test_colorbar_positioned_using_normalized_coords():
58-
"""
59-
Create colorbar at normalized coordinates 0.75,0.25 with length 2cm.
60-
"""
61-
fig = Figure()
62-
fig.basemap(region=[2, 4, 6, 8], projection="t0/2c", frame=True)
63-
fig.colorbar(cmap="rainbow", position="n0.75/0.25+w2c")
64-
return fig
656

667

678
@pytest.mark.mpl_image_compare
@@ -74,16 +15,6 @@ def test_colorbar_box():
7415
return fig
7516

7617

77-
@pytest.mark.mpl_image_compare
78-
def test_colorbar_box_with_pen():
79-
"""
80-
Create colorbar with box that has a different colored pen.
81-
"""
82-
fig = Figure()
83-
fig.colorbar(cmap="rainbow", box="+porange", position="x0c/0c+w1c/0.5c")
84-
return fig
85-
86-
8718
@pytest.mark.mpl_image_compare
8819
def test_colorbar_box_with_fill():
8920
"""
@@ -94,48 +25,6 @@ def test_colorbar_box_with_fill():
9425
return fig
9526

9627

97-
@pytest.mark.mpl_image_compare
98-
def test_colorbar_box_with_clearance():
99-
"""
100-
Create colorbar with box that has an x-clearance of 0.8cm and y-clearance
101-
of 0.4cm.
102-
"""
103-
fig = Figure()
104-
fig.colorbar(cmap="rainbow", box="+c0.8c/0.4c+porange", position="x0c/0c+w1c/0.5c")
105-
return fig
106-
107-
108-
@pytest.mark.mpl_image_compare
109-
def test_colorbar_box_with_secondary_border():
110-
"""
111-
Create colorbar with box that has a secondary, inner border in addition to
112-
the main primary, outer border.
113-
"""
114-
fig = Figure()
115-
fig.colorbar(cmap="rainbow", box="+porange+imagenta", position="x0c/0c+w1c/0.5c")
116-
return fig
117-
118-
119-
@pytest.mark.mpl_image_compare
120-
def test_colorbar_box_with_rounded_corners():
121-
"""
122-
Create colorbar with box that has rounded corners.
123-
"""
124-
fig = Figure()
125-
fig.colorbar(cmap="rainbow", box="+porange+r", position="x0c/0c+w1c/0.5c")
126-
return fig
127-
128-
129-
@pytest.mark.mpl_image_compare
130-
def test_colorbar_box_with_offset_background():
131-
"""
132-
Create colorbar with box and an offset background shaded region.
133-
"""
134-
fig = Figure()
135-
fig.colorbar(cmap="rainbow", box="+s5p/-5p", position="x0c/0c+w1c/0.5c")
136-
return fig
137-
138-
13928
@pytest.mark.mpl_image_compare
14029
def test_colorbar_truncated_to_zlow_zhigh():
14130
"""
@@ -156,61 +45,23 @@ def test_colorbar_scaled_z_values():
15645
return fig
15746

15847

159-
@check_figures_equal()
48+
@pytest.mark.mpl_image_compare
16049
def test_colorbar_shading_boolean():
16150
"""
16251
Create colorbar and set shading with a Boolean value.
16352
"""
164-
fig_ref, fig_test = Figure(), Figure()
165-
# Use single-character arguments for the reference image
166-
fig_ref.basemap(R="0/10/0/10", J="X15c", B="a")
167-
fig_ref.colorbar(C="geo", I="")
168-
169-
fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
170-
fig_test.colorbar(cmap="geo", shading=True)
171-
return fig_ref, fig_test
172-
173-
174-
@check_figures_equal()
175-
def test_colorbar_shading_float():
176-
"""
177-
Create colorbar and set shading with a single float variable.
178-
"""
179-
fig_ref, fig_test = Figure(), Figure()
180-
# Use single-character arguments for the reference image
181-
fig_ref.basemap(R="0/10/0/10", J="X15c", B="a")
182-
fig_ref.colorbar(C="geo", I=0.5)
183-
184-
fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
185-
fig_test.colorbar(cmap="geo", shading=0.5)
186-
return fig_ref, fig_test
187-
188-
189-
@check_figures_equal()
190-
def test_colorbar_shading_string():
191-
"""
192-
Create colorbar and set shading by passing the low/high values as a string.
193-
"""
194-
fig_ref, fig_test = Figure(), Figure()
195-
# Use single-character arguments for the reference image
196-
fig_ref.basemap(R="0/10/0/10", J="X15c", B="a")
197-
fig_ref.colorbar(C="geo", I="-0.7/0.2")
198-
199-
fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
200-
fig_test.colorbar(cmap="geo", shading="-0.7/0.2")
201-
return fig_ref, fig_test
53+
fig = Figure()
54+
fig.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
55+
fig.colorbar(cmap="geo", shading=True, frame=True)
56+
return fig
20257

20358

204-
@check_figures_equal()
59+
@pytest.mark.mpl_image_compare
20560
def test_colorbar_shading_list():
20661
"""
20762
Create colorbar and set shading by passing the high/low values as a list.
20863
"""
209-
fig_ref, fig_test = Figure(), Figure()
210-
# Use single-character arguments for the reference image
211-
fig_ref.basemap(R="0/10/0/10", J="X15c", B="a")
212-
fig_ref.colorbar(C="geo", I="-0.7/0.2")
213-
214-
fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
215-
fig_test.colorbar(cmap="geo", shading=[-0.7, 0.2])
216-
return fig_ref, fig_test
64+
fig = Figure()
65+
fig.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
66+
fig.colorbar(cmap="geo", shading=[-0.7, 0.2], frame=True)
67+
return fig

0 commit comments

Comments
 (0)