Skip to content

Commit 3b70672

Browse files
committed
Rename value_to_string to to_string
1 parent 6499b84 commit 3b70672

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

pygmt/alias.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pygmt.helpers.utils import is_nonstr_iter
1111

1212

13-
def value_to_string(
13+
def to_string(
1414
value: Any,
1515
prefix: str = "", # Default to an empty string to simplify the code logic.
1616
separator: Literal["/", ","] | None = None,
@@ -59,29 +59,29 @@ def value_to_string(
5959
6060
Examples
6161
--------
62-
>>> value_to_string("text")
62+
>>> to_string("text")
6363
'text'
64-
>>> value_to_string(12)
64+
>>> to_string(12)
6565
'12'
66-
>>> value_to_string((12, 34), separator="/")
66+
>>> to_string((12, 34), separator="/")
6767
'12/34'
68-
>>> value_to_string(("12p", "34p"), separator=",")
68+
>>> to_string(("12p", "34p"), separator=",")
6969
'12p,34p'
70-
>>> value_to_string(("12p", "34p"), prefix="+o", separator="/")
70+
>>> to_string(("12p", "34p"), prefix="+o", separator="/")
7171
'+o12p/34p'
72-
>>> value_to_string(True)
72+
>>> to_string(True)
7373
''
74-
>>> value_to_string(True, prefix="+a")
74+
>>> to_string(True, prefix="+a")
7575
'+a'
76-
>>> value_to_string(False)
77-
>>> value_to_string(None)
78-
>>> value_to_string(["xaf", "yaf", "WSen"])
76+
>>> to_string(False)
77+
>>> to_string(None)
78+
>>> to_string(["xaf", "yaf", "WSen"])
7979
['xaf', 'yaf', 'WSen']
80-
>>> value_to_string("high", mapping=True)
80+
>>> to_string("high", mapping=True)
8181
'h'
82-
>>> value_to_string("mean", mapping={"mean": "a", "mad": "d", "full": "g"})
82+
>>> to_string("mean", mapping={"mean": "a", "mad": "d", "full": "g"})
8383
'a'
84-
>>> value_to_string("invalid", mapping={"mean": "a", "mad": "d", "full": "g"})
84+
>>> to_string("invalid", mapping={"mean": "a", "mad": "d", "full": "g"})
8585
'invalid'
8686
"""
8787
# Return None if the value is None or False.
@@ -142,7 +142,7 @@ def __init__(
142142
separator: Literal["/", ","] | None = None,
143143
mapping: bool | Mapping = False,
144144
):
145-
self.value = value_to_string(
145+
self.value = to_string(
146146
value=value, prefix=prefix, separator=separator, mapping=mapping
147147
)
148148

0 commit comments

Comments
 (0)