Skip to content

Commit c893755

Browse files
committed
Improve comment in to_string
1 parent dea66ea commit c893755

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pygmt/alias.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ def to_string(
1919
"""
2020
Convert any value to a string, a sequence of strings or None.
2121
22-
- ``None`` or ``False`` will be converted to ``None``.
22+
The general rules are:
23+
24+
- ``None``/``False`` will be converted to ``None``.
2325
- ``True`` will be converted to an empty string.
2426
- A sequence will be joined by the separator if a separator is provided. Otherwise,
2527
each item in the sequence will be converted to a string and a sequence of strings
2628
will be returned.
27-
- Any other value will be converted to a string if possible.
29+
- Any other type of values will be converted to a string if possible.
2830
2931
If a mapping dictionary is provided, the value will be converted to the short-form
3032
string that GMT accepts (e.g., mapping PyGMT long-form argument ``"high"`` to GMT's
@@ -35,10 +37,10 @@ def to_string(
3537
An optional prefix (e.g., `"+o"`) can be added to the beginning of the converted
3638
string.
3739
38-
Need to note that this function doesn't check if the given parameters are valid, to
39-
avoid the overhead of checking. For example, if ``value`` is a sequence but
40-
``separator`` is not specified, a sequence of strings will be returned. ``prefix``
41-
makes no sense here, but this function won't check it.
40+
To avoid extra overhead, this function does not validate parameter combinations. For
41+
example, if ``value`` is a sequence but ``separator`` is not specified, the function
42+
will return a sequence of strings. In this case, ``prefix`` has no effect, but the
43+
function does not check for such inconsistencies.
4244
4345
Parameters
4446
----------

0 commit comments

Comments
 (0)