Skip to content
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

Add GMTInvalidInput Error for Figure.coast #787

Merged
merged 11 commits into from
Jan 20, 2021
6 changes: 6 additions & 0 deletions pygmt/base_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pygmt.clib import Session
from pygmt.exceptions import GMTError, GMTInvalidInput
from pygmt.helpers import (
args_in_kwargs,
build_arg_string,
data_kind,
dummy_context,
Expand Down Expand Up @@ -167,6 +168,11 @@ def coast(self, **kwargs):

"""
kwargs = self._preprocess(**kwargs)
if not args_in_kwargs(args=["C", "G", "S", "I", "N", "Q", "W"], kwargs=kwargs):
raise GMTInvalidInput(
"""At least one of the following arguments must be specified:
lakes, land, water, rivers, borders, Q, or shorelines"""
)
with Session() as lib:
lib.call_module("coast", build_arg_string(kwargs))

Expand Down
8 changes: 8 additions & 0 deletions pygmt/tests/test_coast.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import pytest
from pygmt import Figure
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers.testing import check_figures_equal


Expand Down Expand Up @@ -97,6 +98,13 @@ def test_coast_world_mercator():
return fig


def test_coast_required_args():
"Test if fig.coast fails when not given required arguments"
fig = Figure()
with pytest.raises(GMTInvalidInput):
fig.coast(region="EG")


@check_figures_equal()
def test_coast_dcw_single():
"Test passing a single country code to dcw"
Expand Down