Skip to content

Migrate Figure.colorbar tests to use dvc #1143

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 24 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f740dbf
remove test_colorbar_using_paper_coordinates_horizontal()
willschlitzer Mar 28, 2021
ce433df
remove test_colorbar_using_paper_coordinates_horizontal.png
willschlitzer Mar 28, 2021
751939f
remove test_colorbar_box_with_rounded_corners()
willschlitzer Mar 28, 2021
ec619d0
remove test_colorbar_shading_string()
willschlitzer Mar 28, 2021
e1659cc
run make format
willschlitzer Mar 28, 2021
d0ac30d
Merge branch 'master' into test-colobar-dvc
weiji14 Mar 30, 2021
b5cdf78
remove test_colorbar_positioned_using_justification_code()
willschlitzer Mar 30, 2021
c490119
remove test_colorbar_box_with_secondary_border()
willschlitzer Mar 30, 2021
cc3635d
remove test_colorbar_box_with_clearance()
willschlitzer Mar 30, 2021
1ba043c
remove test_colorbar_box_with_pen()
willschlitzer Mar 30, 2021
ef2c1b6
remove test_colorbar_box_with_offset_background()
willschlitzer Mar 30, 2021
b748582
update test_colorbar_shading_boolean() to use mpl_image_compare
willschlitzer Mar 30, 2021
26d5871
remove test_color_shading_float and update test_colorbar_shading_list…
willschlitzer Mar 30, 2021
928fb24
run make format
willschlitzer Mar 30, 2021
37851c7
remove .png files, add .dvc files
willschlitzer Mar 30, 2021
4a6110e
Merge branch 'master' into test-colobar-dvc
willschlitzer Mar 30, 2021
8a9c4b3
remove unused import
willschlitzer Mar 30, 2021
fed33a1
remove test_colorbar_positioned_using_normalized_coords()
willschlitzer Mar 30, 2021
d262655
remove test_colorbar_positioned_using_map_coordinates()
willschlitzer Mar 30, 2021
20fad44
remove test_colorbar_using_paper_coordinates()
willschlitzer Mar 30, 2021
3fc1d4c
Merge branch 'master' into test-colobar-dvc
willschlitzer Apr 2, 2021
09aa38b
Apply suggestions from code review
willschlitzer Apr 2, 2021
73804f7
update dvc files for test_colobar_shading_boolean and test_colorbar_s…
willschlitzer Apr 2, 2021
751b212
Merge branch 'master' into test-colobar-dvc
seisman Apr 2, 2021
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_colorbar_box.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_colorbar_box.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 6b0f073c0adc00a3c93693ee22e92b6b
size: 1522
path: test_colorbar_box.png
Binary file not shown.
Binary file removed pygmt/tests/baseline/test_colorbar_box_with_fill.png
Binary file not shown.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_colorbar_box_with_fill.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: f8971e61c1e44c95156372f39913b945
size: 1454
path: test_colorbar_box_with_fill.png
Binary file not shown.
Binary file removed pygmt/tests/baseline/test_colorbar_box_with_pen.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.
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_colorbar_scaled_z_values.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 513afcc325c918500f3b3c8de86cd63c
size: 1870
path: test_colorbar_scaled_z_values.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_colorbar_shading_boolean.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 056c3872738c08667a816f49c676418f
size: 54042
path: test_colorbar_shading_boolean.png
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_colorbar_shading_list.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: e888834c32778bbcfeccaa9fd0d04b1f
size: 59418
path: test_colorbar_shading_list.png
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 03e10c11514fc071f6e970c6babfd6c8
size: 2542
path: test_colorbar_truncated_to_zlow_zhigh.png
Binary file not shown.
Binary file not shown.
169 changes: 10 additions & 159 deletions pygmt/tests/test_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,6 @@
"""
import pytest
from pygmt import Figure
from pygmt.helpers.testing import check_figures_equal


@pytest.mark.mpl_image_compare
def test_colorbar_using_paper_coordinates():
"""
Create colorbar positioned at 0cm,0cm with length 1cm and width 0.5cm.
"""
fig = Figure()
fig.colorbar(cmap="rainbow", position="x0c/0c+w1c/0.5c")
return fig


@pytest.mark.mpl_image_compare
def test_colorbar_using_paper_coordinates_horizontal():
"""
Create colorbar positioned at 0cm,0cm with length 2cm oriented
horizontally.
"""
fig = Figure()
fig.colorbar(cmap="rainbow", position="x0c/0c+w2c+h")
return fig


@pytest.mark.mpl_image_compare
def test_colorbar_positioned_using_map_coordinates():
"""
Create colorbar positioned at longitude,latitude 3,6 with length 2cm.
"""
fig = Figure()
fig.basemap(region=[2, 4, 6, 8], projection="t0/2c", frame=True)
fig.colorbar(cmap="rainbow", position="g3/6+w2c")
return fig


@check_figures_equal()
def test_colorbar_positioned_using_justification_code():
"""
Create colorbar at Top Center inside the map frame with length 2cm.
"""
fig_ref, fig_test = Figure(), Figure()
# Use single-character arguments for the reference image
fig_ref.basemap(R="2/4/6/8", J="t0/2c", B="")
fig_ref.colorbar(C="rainbow", D="jTC+w2c")

fig_test.basemap(region=[2, 4, 6, 8], projection="t0/2c", frame=True)
fig_test.colorbar(cmap="rainbow", position="jTC+w2c")
return fig_ref, fig_test


@pytest.mark.mpl_image_compare
def test_colorbar_positioned_using_normalized_coords():
"""
Create colorbar at normalized coordinates 0.75,0.25 with length 2cm.
"""
fig = Figure()
fig.basemap(region=[2, 4, 6, 8], projection="t0/2c", frame=True)
fig.colorbar(cmap="rainbow", position="n0.75/0.25+w2c")
return fig


@pytest.mark.mpl_image_compare
Expand All @@ -74,16 +15,6 @@ def test_colorbar_box():
return fig


@pytest.mark.mpl_image_compare
def test_colorbar_box_with_pen():
"""
Create colorbar with box that has a different colored pen.
"""
fig = Figure()
fig.colorbar(cmap="rainbow", box="+porange", position="x0c/0c+w1c/0.5c")
return fig


@pytest.mark.mpl_image_compare
def test_colorbar_box_with_fill():
"""
Expand All @@ -94,48 +25,6 @@ def test_colorbar_box_with_fill():
return fig


@pytest.mark.mpl_image_compare
def test_colorbar_box_with_clearance():
"""
Create colorbar with box that has an x-clearance of 0.8cm and y-clearance
of 0.4cm.
"""
fig = Figure()
fig.colorbar(cmap="rainbow", box="+c0.8c/0.4c+porange", position="x0c/0c+w1c/0.5c")
return fig


@pytest.mark.mpl_image_compare
def test_colorbar_box_with_secondary_border():
"""
Create colorbar with box that has a secondary, inner border in addition to
the main primary, outer border.
"""
fig = Figure()
fig.colorbar(cmap="rainbow", box="+porange+imagenta", position="x0c/0c+w1c/0.5c")
return fig


@pytest.mark.mpl_image_compare
def test_colorbar_box_with_rounded_corners():
"""
Create colorbar with box that has rounded corners.
"""
fig = Figure()
fig.colorbar(cmap="rainbow", box="+porange+r", position="x0c/0c+w1c/0.5c")
return fig


@pytest.mark.mpl_image_compare
def test_colorbar_box_with_offset_background():
"""
Create colorbar with box and an offset background shaded region.
"""
fig = Figure()
fig.colorbar(cmap="rainbow", box="+s5p/-5p", position="x0c/0c+w1c/0.5c")
return fig


@pytest.mark.mpl_image_compare
def test_colorbar_truncated_to_zlow_zhigh():
"""
Expand All @@ -156,61 +45,23 @@ def test_colorbar_scaled_z_values():
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_colorbar_shading_boolean():
"""
Create colorbar and set shading with a Boolean value.
"""
fig_ref, fig_test = Figure(), Figure()
# Use single-character arguments for the reference image
fig_ref.basemap(R="0/10/0/10", J="X15c", B="a")
fig_ref.colorbar(C="geo", I="")

fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
fig_test.colorbar(cmap="geo", shading=True)
return fig_ref, fig_test


@check_figures_equal()
def test_colorbar_shading_float():
"""
Create colorbar and set shading with a single float variable.
"""
fig_ref, fig_test = Figure(), Figure()
# Use single-character arguments for the reference image
fig_ref.basemap(R="0/10/0/10", J="X15c", B="a")
fig_ref.colorbar(C="geo", I=0.5)

fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
fig_test.colorbar(cmap="geo", shading=0.5)
return fig_ref, fig_test


@check_figures_equal()
def test_colorbar_shading_string():
"""
Create colorbar and set shading by passing the low/high values as a string.
"""
fig_ref, fig_test = Figure(), Figure()
# Use single-character arguments for the reference image
fig_ref.basemap(R="0/10/0/10", J="X15c", B="a")
fig_ref.colorbar(C="geo", I="-0.7/0.2")

fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
fig_test.colorbar(cmap="geo", shading="-0.7/0.2")
return fig_ref, fig_test
fig = Figure()
fig.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
fig.colorbar(cmap="geo", shading=True, frame=True)
return fig


@check_figures_equal()
@pytest.mark.mpl_image_compare
def test_colorbar_shading_list():
"""
Create colorbar and set shading by passing the high/low values as a list.
"""
fig_ref, fig_test = Figure(), Figure()
# Use single-character arguments for the reference image
fig_ref.basemap(R="0/10/0/10", J="X15c", B="a")
fig_ref.colorbar(C="geo", I="-0.7/0.2")

fig_test.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
fig_test.colorbar(cmap="geo", shading=[-0.7, 0.2])
return fig_ref, fig_test
fig = Figure()
fig.basemap(region=[0, 10, 0, 10], projection="X15c", frame="a")
fig.colorbar(cmap="geo", shading=[-0.7, 0.2], frame=True)
return fig