MCPcopy
hub / github.com/pydata/xarray / bytes_to_char

Function bytes_to_char

xarray/coding/strings.py:177–192  ·  view source on GitHub ↗

Convert numpy/dask arrays from fixed width bytes to characters.

(arr)

Source from the content-addressed store, hash-verified

175
176
177def bytes_to_char(arr):
178 """Convert numpy/dask arrays from fixed width bytes to characters."""
179 if arr.dtype.kind != "S":
180 raise ValueError("argument must have a fixed-width bytes dtype")
181
182 if is_chunked_array(arr):
183 chunkmanager = get_chunked_array_type(arr)
184
185 return chunkmanager.map_blocks(
186 _numpy_bytes_to_char,
187 arr,
188 dtype="S1",
189 chunks=arr.chunks + ((arr.dtype.itemsize,)),
190 new_axis=[arr.ndim],
191 )
192 return _numpy_bytes_to_char(arr)
193
194
195def _numpy_bytes_to_char(arr):

Callers 1

encodeMethod · 0.85

Calls 4

is_chunked_arrayFunction · 0.90
get_chunked_array_typeFunction · 0.90
_numpy_bytes_to_charFunction · 0.85
map_blocksMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…