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

Function _numpy_bytes_to_char

xarray/coding/strings.py:195–203  ·  view source on GitHub ↗

Like netCDF4.stringtochar, but faster and more flexible.

(arr)

Source from the content-addressed store, hash-verified

193
194
195def _numpy_bytes_to_char(arr):
196 """Like netCDF4.stringtochar, but faster and more flexible."""
197 # adapt handling of copy-kwarg to numpy 2.0
198 # see https://github.com/numpy/numpy/issues/25916
199 # and https://github.com/numpy/numpy/pull/25922
200 copy = None if HAS_NUMPY_2_0 else False
201 # ensure the array is contiguous
202 arr = np.array(arr, copy=copy, order="C", dtype=np.bytes_)
203 return arr.reshape(arr.shape + (1,)).view("S1")
204
205
206def char_to_bytes(arr):

Callers 1

bytes_to_charFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…