Skip to content

Commit

Permalink
Add a test to make sure shift_origin does not crash (#580)
Browse files Browse the repository at this point in the history
* Add a test to make sure shift_origin does not crash
* Use long arguments instead of short ones
  • Loading branch information
seisman authored Sep 4, 2020
1 parent 97a585b commit 08aa36f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pygmt/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_figure_region_country_codes():
def test_figure_savefig_exists():
"Make sure the saved figure has the right name"
fig = Figure()
fig.basemap(region="10/70/-300/800", J="X3i/5i", B="af")
fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af")
prefix = "test_figure_savefig_exists"
for fmt in "png pdf jpg bmp eps tif".split():
fname = ".".join([prefix, fmt])
Expand All @@ -60,7 +60,7 @@ def test_figure_savefig_exists():
def test_figure_savefig_transparent():
"Check if fails when transparency is not supported"
fig = Figure()
fig.basemap(region="10/70/-300/800", J="X3i/5i", B="af")
fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af")
prefix = "test_figure_savefig_transparent"
for fmt in "pdf jpg bmp eps tif".split():
fname = ".".join([prefix, fmt])
Expand Down Expand Up @@ -112,7 +112,7 @@ def mock_psconvert(*args, **kwargs): # pylint: disable=unused-argument
def test_figure_show():
"Test that show creates the correct file name and deletes the temp dir"
fig = Figure()
fig.basemap(R="10/70/-300/800", J="X3i/5i", B="af")
fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af")
img = fig.show(width=800)
assert img.width == 800

Expand All @@ -121,11 +121,14 @@ def test_figure_show():
def test_shift_origin():
"Test if fig.shift_origin works"
fig = Figure()
fig.basemap(R="10/70/-300/300", J="X3i/5i", B="af")
# First call shift_origin without projection and region.
# Test the issue https://github.com/GenericMappingTools/pygmt/issues/514
fig.shift_origin(xshift="2i", yshift="3i")
fig.basemap(region="10/70/-300/300", projection="X3i/5i", frame="af")
fig.shift_origin(xshift="4i")
fig.basemap(R="10/70/-300/300", J="X3i/5i", B="af")
fig.basemap(region="10/70/-300/300", projection="X3i/5i", frame="af")
fig.shift_origin(yshift="6i")
fig.basemap(R="10/70/-300/300", J="X3i/5i", B="af")
fig.basemap(region="10/70/-300/300", projection="X3i/5i", frame="af")
fig.shift_origin(xshift="-4i", yshift="6i")
fig.basemap(R="10/70/-300/300", J="X3i/5i", B="af")
fig.basemap(region="10/70/-300/300", projection="X3i/5i", frame="af")
return fig

0 comments on commit 08aa36f

Please sign in to comment.