Skip to content

Commit c1407f5

Browse files
Improve the error message when GMTInvalidInput error is raised for basemap (#729)
1 parent 9aa3d36 commit c1407f5

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

pygmt/base_plotting.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,10 @@ def basemap(self, **kwargs):
11671167
11681168
"""
11691169
kwargs = self._preprocess(**kwargs)
1170-
if not ("B" in kwargs or "L" in kwargs or "T" in kwargs):
1171-
raise GMTInvalidInput("At least one of B, L, or T must be specified.")
1170+
if not ("B" in kwargs or "L" in kwargs or "Td" in kwargs or "Tm" in kwargs):
1171+
raise GMTInvalidInput(
1172+
"At least one of frame, map_scale, compass, or rose must be specified."
1173+
)
11721174
with Session() as lib:
11731175
lib.call_module("basemap", build_arg_string(kwargs))
11741176

pygmt/tests/test_basemap.py

+22
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,25 @@ def test_basemap_aliases():
8080
fig = Figure()
8181
fig.basemap(region=[0, 360, -90, 90], projection="W7i", frame=True)
8282
return fig
83+
84+
85+
@check_figures_equal()
86+
def test_basemap_rose():
87+
"Create a map with coast and use basemap to add a rose"
88+
fig_ref, fig_test = Figure(), Figure()
89+
fig_ref.coast(R="127.5/128.5/26/27", W="1/0.5p")
90+
fig_ref.basemap(Td="jBR+w5c")
91+
fig_test.coast(region=[127.5, 128.5, 26, 27], shorelines="1/0.5p")
92+
fig_test.basemap(rose="jBR+w5c")
93+
return fig_ref, fig_test
94+
95+
96+
@check_figures_equal()
97+
def test_basemap_compass():
98+
"Create a map with coast and use basemap to add a compass"
99+
fig_ref, fig_test = Figure(), Figure()
100+
fig_ref.coast(R="127.5/128.5/26/27", W="1/0.5p")
101+
fig_ref.basemap(Tm="jBR+w5c+d11.5")
102+
fig_test.coast(region=[127.5, 128.5, 26, 27], shorelines="1/0.5p")
103+
fig_test.basemap(compass="jBR+w5c+d11.5")
104+
return fig_ref, fig_test

0 commit comments

Comments
 (0)