summaryrefslogtreecommitdiff
path: root/numpy/core/defchararray.py
diff options
context:
space:
mode:
authorBrent Tan <73753023+BrentTanKian@users.noreply.github.com>2022-09-19 18:00:18 +0800
committerGitHub <noreply@github.com>2022-09-19 12:00:18 +0200
commitbecf417a55bbfc985a350cfb673b26e248af4542 (patch)
tree7c234c315f3bacadb59579ed53642be3c4145de7 /numpy/core/defchararray.py
parent7f43baa7b24ec36b65426428209901c7599c41ef (diff)
downloadnumpy-becf417a55bbfc985a350cfb673b26e248af4542.tar.gz
DOC: Correct usage example for np.char.decode docstring (#22309)
The docstring was previously a copy-paste error from `encode` rather than `decode`.
Diffstat (limited to 'numpy/core/defchararray.py')
-rw-r--r--numpy/core/defchararray.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py
index 56f93af31..fe6694087 100644
--- a/numpy/core/defchararray.py
+++ b/numpy/core/defchararray.py
@@ -545,8 +545,8 @@ def _code_dispatcher(a, encoding=None, errors=None):
@array_function_dispatch(_code_dispatcher)
def decode(a, encoding=None, errors=None):
- """
- Calls `str.decode` element-wise.
+ r"""
+ Calls ``bytes.decode`` element-wise.
The set of available codecs comes from the Python standard library,
and may be extended at runtime. For more information, see the
@@ -568,7 +568,7 @@ def decode(a, encoding=None, errors=None):
See Also
--------
- str.decode
+ :py:meth:`bytes.decode`
Notes
-----
@@ -576,13 +576,13 @@ def decode(a, encoding=None, errors=None):
Examples
--------
- >>> c = np.array(['aAaAaA', ' aA ', 'abBABba'])
+ >>> c = np.array([b'\x81\xc1\x81\xc1\x81\xc1', b'@@\x81\xc1@@',
+ ... b'\x81\x82\xc2\xc1\xc2\x82\x81'])
>>> c
+ array([b'\x81\xc1\x81\xc1\x81\xc1', b'@@\x81\xc1@@',
+ ... b'\x81\x82\xc2\xc1\xc2\x82\x81'], dtype='|S7')
+ >>> np.char.decode(c, encoding='cp037')
array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7')
- >>> np.char.encode(c, encoding='cp037')
- array(['\\x81\\xc1\\x81\\xc1\\x81\\xc1', '@@\\x81\\xc1@@',
- '\\x81\\x82\\xc2\\xc1\\xc2\\x82\\x81'],
- dtype='|S7')
"""
return _to_string_or_unicode_array(
@@ -2237,7 +2237,7 @@ class chararray(ndarray):
def decode(self, encoding=None, errors=None):
"""
- Calls `str.decode` element-wise.
+ Calls ``bytes.decode`` element-wise.
See Also
--------