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

Function to_like_array

xarray/compat/array_api_compat.py:76–82  ·  view source on GitHub ↗
(array, like)

Source from the content-addressed store, hash-verified

74
75
76def to_like_array(array, like):
77 # Mostly for cupy compatibility, because cupy binary ops require all cupy arrays
78 xp = get_array_namespace(like)
79 if xp is not np:
80 return xp.asarray(array)
81 # avoid casting things like pint quantities to numpy arrays
82 return array

Callers 3

_integrate_oneMethod · 0.90
_getitem_with_maskMethod · 0.90
_calc_idxminmaxFunction · 0.90

Calls 1

get_array_namespaceFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…