Skip to content

Commit 38e2c73

Browse files
committed
Add more doctests to Alias
1 parent 95e6c63 commit 38e2c73

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pygmt/alias.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import dataclasses
66
from collections import defaultdict
7-
from collections.abc import Mapping, Sequence
7+
from collections.abc import Mapping
88
from typing import Any, Literal
99

1010
from pygmt.helpers.utils import is_nonstr_iter
@@ -131,6 +131,18 @@ class Alias:
131131
>>> par = Alias(["xaf", "yaf", "WSen"])
132132
>>> par._value
133133
['xaf', 'yaf', 'WSen']
134+
135+
>>> par = Alias("high", mapping=True)
136+
>>> par._value
137+
'h'
138+
139+
>>> par = Alias("mean", mapping={"mean": "a", "mad": "d", "full": "g"})
140+
>>> par._value
141+
'a'
142+
143+
>>> par = Alias("invalid", mapping={"mean": "a", "mad": "d", "full": "g"})
144+
>>> par._value
145+
'invalid'
134146
"""
135147

136148
value: Any
@@ -139,7 +151,7 @@ class Alias:
139151
mapping: bool | Mapping = False
140152

141153
@property
142-
def _value(self) -> str | Sequence[str] | None:
154+
def _value(self) -> str | list[str] | None:
143155
"""
144156
The value of the alias as a string, a sequence of strings or None.
145157
"""

0 commit comments

Comments
 (0)