MCPcopy Create free account
hub / github.com/numpy/numpy / _to_bytes_or_str_array

Function _to_bytes_or_str_array

numpy/core/defchararray.py:60–70  ·  view source on GitHub ↗

Helper function to cast a result back into an array with the appropriate dtype if an object array must be used as an intermediary.

(result, output_dtype_like=None)

Source from the content-addressed store, hash-verified

58
59
60def _to_bytes_or_str_array(result, output_dtype_like=None):
61 """
62 Helper function to cast a result back into an array
63 with the appropriate dtype if an object array must be used
64 as an intermediary.
65 """
66 ret = numpy.asarray(result.tolist())
67 dtype = getattr(output_dtype_like, 'dtype', None)
68 if dtype is not None:
69 return ret.astype(type(dtype)(_get_num_chars(ret)), copy=False)
70 return ret
71
72
73def _clean_args(*args):

Callers 8

modFunction · 0.85
decodeFunction · 0.85
encodeFunction · 0.85
expandtabsFunction · 0.85
joinFunction · 0.85
partitionFunction · 0.85
replaceFunction · 0.85
rpartitionFunction · 0.85

Calls 3

_get_num_charsFunction · 0.85
astypeMethod · 0.80
tolistMethod · 0.45

Tested by

no test coverage detected