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 :mod:`codecs` module. Parameters ---------- a : array_like of str or unicode encoding : str,
(a, encoding=None, errors=None)
| 571 | |
| 572 | @array_function_dispatch(_code_dispatcher) |
| 573 | def decode(a, encoding=None, errors=None): |
| 574 | r""" |
| 575 | Calls ``bytes.decode`` element-wise. |
| 576 | |
| 577 | The set of available codecs comes from the Python standard library, |
| 578 | and may be extended at runtime. For more information, see the |
| 579 | :mod:`codecs` module. |
| 580 | |
| 581 | Parameters |
| 582 | ---------- |
| 583 | a : array_like of str or unicode |
| 584 | |
| 585 | encoding : str, optional |
| 586 | The name of an encoding |
| 587 | |
| 588 | errors : str, optional |
| 589 | Specifies how to handle encoding errors |
| 590 | |
| 591 | Returns |
| 592 | ------- |
| 593 | out : ndarray |
| 594 | |
| 595 | See Also |
| 596 | -------- |
| 597 | :py:meth:`bytes.decode` |
| 598 | |
| 599 | Notes |
| 600 | ----- |
| 601 | The type of the result will depend on the encoding specified. |
| 602 | |
| 603 | Examples |
| 604 | -------- |
| 605 | >>> c = np.array([b'\x81\xc1\x81\xc1\x81\xc1', b'@@\x81\xc1@@', |
| 606 | ... b'\x81\x82\xc2\xc1\xc2\x82\x81']) |
| 607 | >>> c |
| 608 | array([b'\x81\xc1\x81\xc1\x81\xc1', b'@@\x81\xc1@@', |
| 609 | ... b'\x81\x82\xc2\xc1\xc2\x82\x81'], dtype='|S7') |
| 610 | >>> np.char.decode(c, encoding='cp037') |
| 611 | array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7') |
| 612 | |
| 613 | """ |
| 614 | return _to_bytes_or_str_array( |
| 615 | _vec_string(a, object_, 'decode', _clean_args(encoding, errors))) |
| 616 | |
| 617 | |
| 618 | @array_function_dispatch(_code_dispatcher) |
no test coverage detected