-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Figure.shift_origin tests into a separate test file (#3590)
- Loading branch information
Showing
4 changed files
with
48 additions
and
40 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
outs: | ||
- md5: 39b241fdd879271cf1e8cf1f73454706 | ||
size: 9910 | ||
hash: md5 | ||
path: test_shift_origin.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Test Figure.shift_origin. | ||
""" | ||
|
||
import pytest | ||
from pygmt.exceptions import GMTInvalidInput | ||
from pygmt.figure import Figure | ||
|
||
|
||
@pytest.mark.mpl_image_compare | ||
def test_shift_origin(): | ||
""" | ||
Test if fig.shift_origin works. | ||
""" | ||
kwargs = {"region": [0, 3, 0, 5], "projection": "X3c/5c", "frame": 0} | ||
fig = Figure() | ||
# First call shift_origin without projection and region. | ||
# Test issue https://github.com/GenericMappingTools/pygmt/issues/514 | ||
fig.shift_origin(xshift="2c", yshift="3c") | ||
fig.basemap(**kwargs) | ||
fig.shift_origin(xshift="4c") | ||
fig.basemap(**kwargs) | ||
fig.shift_origin(yshift="6c") | ||
fig.basemap(**kwargs) | ||
fig.shift_origin(xshift="-4c", yshift="6c") | ||
fig.basemap(**kwargs) | ||
return fig | ||
|
||
|
||
def test_shift_origin_unsupported_xshift_yshift(): | ||
""" | ||
Raise an exception if X/Y/xshift/yshift is used. | ||
""" | ||
fig = Figure() | ||
fig.basemap(region=[0, 1, 0, 1], projection="X1c/1c", frame=True) | ||
with pytest.raises(GMTInvalidInput): | ||
fig.plot(x=1, y=1, style="c3c", xshift="3c") | ||
with pytest.raises(GMTInvalidInput): | ||
fig.plot(x=1, y=1, style="c3c", X="3c") | ||
with pytest.raises(GMTInvalidInput): | ||
fig.plot(x=1, y=1, style="c3c", yshift="3c") | ||
with pytest.raises(GMTInvalidInput): | ||
fig.plot(x=1, y=1, style="c3c", Y="3c") |