Skip to content

Commit 8c46b9a

Browse files
committed
Add tests
1 parent e4e1759 commit 8c46b9a

File tree

5 files changed

+54
-5
lines changed

5 files changed

+54
-5
lines changed

pygmt/src/directional_rose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pygmt.helpers import build_arg_list
1212

1313

14-
def directional_rose( # noqa: PLR0913
14+
def directional_rose(
1515
self,
1616
position: Sequence[str | float] | AnchorCode,
1717
position_type: Literal[
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
outs:
2+
- md5: 9f1971f6e2b5b87d42f21d7410149793
3+
size: 14718
4+
hash: md5
5+
path: test_directional_rose_complex.png

pygmt/tests/test_basemap.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,16 @@ def test_basemap_rose():
9494
Create a map with a rose.
9595
"""
9696
fig = Figure()
97-
fig.basemap(
98-
region=[127.5, 128.5, 26, 27], projection="H15c", frame=True, rose="jMC+w5c"
99-
)
97+
with pytest.warns(
98+
UserWarning,
99+
match=(
100+
"The 'rose' parameter is deprecated and will be removed in a future "
101+
"release. Please use the 'directional_rose' method instead."
102+
),
103+
):
104+
fig.basemap(
105+
region=[127.5, 128.5, 26, 27], projection="H15c", frame=True, rose="jMC+w5c"
106+
)
100107
return fig
101108

102109

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
Test Figure.directional_rose.
3+
"""
4+
5+
import pytest
6+
from pygmt import Figure
7+
8+
9+
@pytest.mark.mpl_image_compare(filename="test_basemap_rose.png")
10+
def test_directional_rose():
11+
"""
12+
Test the Figure.directional_rose method.
13+
"""
14+
fig = Figure()
15+
fig.basemap(region=[127.5, 128.5, 26, 27], projection="H15c", frame=True)
16+
fig.directional_rose(position="MC", position_type="inside", width="5c")
17+
return fig
18+
19+
20+
@pytest.mark.mpl_image_compare
21+
def test_directional_rose_complex():
22+
"""
23+
Test the Figure.directional_rose method with more parameters.
24+
"""
25+
fig = Figure()
26+
fig.basemap(region=[0, 80, -30, 30], projection="M10c", frame=True)
27+
fig.directional_rose(
28+
position=(50, 0),
29+
position_type="mapcoords",
30+
width="1c",
31+
label=["", "", "", "N"],
32+
fancy=2,
33+
anchor_offset=(1, 1),
34+
justify="MC",
35+
)
36+
return fig

pygmt/tests/test_inset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ def test_inset_context_manager():
2929
fig.basemap(region=[-74, -69.5, 41, 43], projection="M9c", frame=True)
3030
with fig.inset(position="jBL+w3c+o0.2c", margin=0, box="+pblack"):
3131
fig.basemap(region=[-80, -65, 35, 50], projection="M3c", frame="afg")
32-
fig.basemap(rose="jTR+w3c") # Pass rose argument with basemap after the inset
32+
# Plot an rose after the inset
33+
fig.directional_rose(position="TR", position_type="inside", width="3c")
3334
return fig

0 commit comments

Comments
 (0)