From becf417a55bbfc985a350cfb673b26e248af4542 Mon Sep 17 00:00:00 2001 From: Brent Tan <73753023+BrentTanKian@users.noreply.github.com> Date: Mon, 19 Sep 2022 18:00:18 +0800 Subject: DOC: Correct usage example for np.char.decode docstring (#22309) The docstring was previously a copy-paste error from `encode` rather than `decode`. --- numpy/core/defchararray.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'numpy/core/defchararray.py') 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='>> 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 -------- -- cgit v1.2.1