Skip to content

Commit 08aa36f

Browse files
authored
Add a test to make sure shift_origin does not crash (#580)
* Add a test to make sure shift_origin does not crash * Use long arguments instead of short ones
1 parent 97a585b commit 08aa36f

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pygmt/tests/test_figure.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_figure_region_country_codes():
4848
def test_figure_savefig_exists():
4949
"Make sure the saved figure has the right name"
5050
fig = Figure()
51-
fig.basemap(region="10/70/-300/800", J="X3i/5i", B="af")
51+
fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af")
5252
prefix = "test_figure_savefig_exists"
5353
for fmt in "png pdf jpg bmp eps tif".split():
5454
fname = ".".join([prefix, fmt])
@@ -60,7 +60,7 @@ def test_figure_savefig_exists():
6060
def test_figure_savefig_transparent():
6161
"Check if fails when transparency is not supported"
6262
fig = Figure()
63-
fig.basemap(region="10/70/-300/800", J="X3i/5i", B="af")
63+
fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af")
6464
prefix = "test_figure_savefig_transparent"
6565
for fmt in "pdf jpg bmp eps tif".split():
6666
fname = ".".join([prefix, fmt])
@@ -112,7 +112,7 @@ def mock_psconvert(*args, **kwargs): # pylint: disable=unused-argument
112112
def test_figure_show():
113113
"Test that show creates the correct file name and deletes the temp dir"
114114
fig = Figure()
115-
fig.basemap(R="10/70/-300/800", J="X3i/5i", B="af")
115+
fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af")
116116
img = fig.show(width=800)
117117
assert img.width == 800
118118

@@ -121,11 +121,14 @@ def test_figure_show():
121121
def test_shift_origin():
122122
"Test if fig.shift_origin works"
123123
fig = Figure()
124-
fig.basemap(R="10/70/-300/300", J="X3i/5i", B="af")
124+
# First call shift_origin without projection and region.
125+
# Test the issue https://github.com/GenericMappingTools/pygmt/issues/514
126+
fig.shift_origin(xshift="2i", yshift="3i")
127+
fig.basemap(region="10/70/-300/300", projection="X3i/5i", frame="af")
125128
fig.shift_origin(xshift="4i")
126-
fig.basemap(R="10/70/-300/300", J="X3i/5i", B="af")
129+
fig.basemap(region="10/70/-300/300", projection="X3i/5i", frame="af")
127130
fig.shift_origin(yshift="6i")
128-
fig.basemap(R="10/70/-300/300", J="X3i/5i", B="af")
131+
fig.basemap(region="10/70/-300/300", projection="X3i/5i", frame="af")
129132
fig.shift_origin(xshift="-4i", yshift="6i")
130-
fig.basemap(R="10/70/-300/300", J="X3i/5i", B="af")
133+
fig.basemap(region="10/70/-300/300", projection="X3i/5i", frame="af")
131134
return fig

0 commit comments

Comments
 (0)