Skip to content

Add a test to make sure shift_origin does not crash #580

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 2 commits into from
Sep 4, 2020
Merged
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
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