Skip to content

Commit 6728856

Browse files
committed
Make check_encoding function private
1 parent 7607c7e commit 6728856

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

pygmt/helpers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
unique_name,
1616
)
1717
from pygmt.helpers.utils import (
18+
_check_encoding,
1819
_validate_data_input,
1920
args_in_kwargs,
2021
build_arg_list,
2122
build_arg_string,
22-
check_encoding,
2323
data_kind,
2424
is_nonstr_iter,
2525
launch_external_viewer,

pygmt/helpers/utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def data_kind(
192192
return kind
193193

194194

195-
def check_encoding(
195+
def _check_encoding(
196196
argstr: str,
197197
) -> Literal[
198198
"ascii",
@@ -233,15 +233,15 @@ def check_encoding(
233233
234234
Examples
235235
--------
236-
>>> check_encoding("123ABC+-?!") # ASCII characters only
236+
>>> _check_encoding("123ABC+-?!") # ASCII characters only
237237
'ascii'
238-
>>> check_encoding("12AB±β①②") # Characters in ISOLatin1+
238+
>>> _check_encoding("12AB±β①②") # Characters in ISOLatin1+
239239
'ISOLatin1+'
240-
>>> check_encoding("12ABāáâãäåβ①②") # Characters in ISO-8859-4
240+
>>> _check_encoding("12ABāáâãäåβ①②") # Characters in ISO-8859-4
241241
'ISO-8859-4'
242-
>>> check_encoding("12ABŒā") # Mix characters in ISOLatin1+ (Œ) and ISO-8859-4 (ā)
242+
>>> _check_encoding("12ABŒā") # Mix characters in ISOLatin1+ (Œ) and ISO-8859-4 (ā)
243243
'ISOLatin1+'
244-
>>> check_encoding("123AB中文") # Characters not in any charset encoding
244+
>>> _check_encoding("123AB中文") # Characters not in any charset encoding
245245
'ISOLatin1+'
246246
"""
247247
# Return "ascii" if the string only contains ASCII characters.
@@ -431,7 +431,7 @@ def build_arg_list( # noqa: PLR0912
431431
gmt_args.append(f"-{key}{value}")
432432

433433
# Convert non-ASCII characters (if any) in the arguments to octal codes
434-
encoding = check_encoding("".join(gmt_args))
434+
encoding = _check_encoding("".join(gmt_args))
435435
if encoding != "ascii":
436436
gmt_args = [non_ascii_to_octal(arg, encoding=encoding) for arg in gmt_args]
437437
gmt_args = sorted(gmt_args)

pygmt/src/text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from pygmt.clib import Session
77
from pygmt.exceptions import GMTInvalidInput
88
from pygmt.helpers import (
9+
_check_encoding,
910
build_arg_list,
10-
check_encoding,
1111
data_kind,
1212
fmt_docstring,
1313
is_nonstr_iter,
@@ -229,7 +229,7 @@ def text_( # noqa: PLR0912
229229
confdict = {}
230230
if kind == "vectors":
231231
text = np.atleast_1d(text).astype(str)
232-
encoding = check_encoding("".join(text))
232+
encoding = _check_encoding("".join(text))
233233
if encoding != "ascii":
234234
text = np.vectorize(non_ascii_to_octal, excluded="encoding")(
235235
text, encoding=encoding

0 commit comments

Comments
 (0)