Skip to content

Commit

Permalink
Move Figure.shift_origin tests into a separate test file (#3590)
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Nov 18, 2024
1 parent 2666531 commit c1a33a7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 40 deletions.
4 changes: 0 additions & 4 deletions pygmt/tests/baseline/test_figure_shift_origin.png.dvc

This file was deleted.

5 changes: 5 additions & 0 deletions pygmt/tests/baseline/test_shift_origin.png.dvc
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
36 changes: 0 additions & 36 deletions pygmt/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,26 +292,6 @@ def test_figure_show():
fig.show()


@pytest.mark.mpl_image_compare
def test_figure_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_figure_show_invalid_method():
"""
Test to check if an error is raised when an invalid method is passed to show.
Expand Down Expand Up @@ -407,22 +387,6 @@ def test_invalid_method(self):
set_display(method="invalid")


def test_figure_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")


class TestGetDefaultDisplayMethod:
"""
Test the _get_default_display_method function.
Expand Down
43 changes: 43 additions & 0 deletions pygmt/tests/test_shift_origin.py
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")

0 comments on commit c1a33a7

Please sign in to comment.