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

basemap: Plotting frames if required parameters are not given #1909

Merged
merged 3 commits into from
Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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