Skip to content

Commit

Permalink
basemap: Plotting frames if required parameters are not given (Generi…
Browse files Browse the repository at this point in the history
…cMappingTools#1909)

Co-authored-by: Michael Grund <[email protected]>
  • Loading branch information
2 people authored and Josh Sixsmith committed Dec 21, 2022
1 parent 2930ac5 commit 8d9729c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 1 addition & 7 deletions pygmt/src/basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

from pygmt.clib import Session
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import (
args_in_kwargs,
build_arg_string,
Expand Down Expand Up @@ -43,9 +42,6 @@ def basemap(self, **kwargs):
tick-mark intervals for boundary annotation, ticking, and [optionally]
gridlines. A simple map scale or directional rose may also be plotted.
At least one of the parameters ``frame``, ``map_scale``, ``rose`` or
``compass`` must be specified.
Full option list at :gmt-docs:`basemap.html`
{aliases}
Expand Down Expand Up @@ -96,8 +92,6 @@ def basemap(self, **kwargs):
"""
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
if not args_in_kwargs(args=["B", "L", "Td", "Tm", "c"], kwargs=kwargs):
raise GMTInvalidInput(
"At least one of frame, map_scale, compass, rose, or panel must be specified."
)
kwargs["B"] = True # Plotting frames if required arguments not given
with Session() as lib:
lib.call_module("basemap", build_arg_string(kwargs))
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_basemap_required_args.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: 36f8200a27d23e19951c2a3823a28faa
size: 6163
path: test_basemap_required_args.png
8 changes: 4 additions & 4 deletions pygmt/tests/test_basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"""
import pytest
from pygmt import Figure
from pygmt.exceptions import GMTInvalidInput


@pytest.mark.mpl_image_compare
def test_basemap_required_args():
"""
Figure.basemap fails when not given required arguments.
Automatically set `frame=True` when required arguments are not given.
"""
fig = Figure()
with pytest.raises(GMTInvalidInput):
fig.basemap(region=[10, 70, -3, 8], projection="X8c/6c")
fig.basemap(region=[10, 70, -3, 8], projection="X8c/6c")
return fig


@pytest.mark.mpl_image_compare
Expand Down

0 comments on commit 8d9729c

Please sign in to comment.