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

Function _get_single_namespace

xarray/compat/array_api_compat.py:50–60  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

48
49def get_array_namespace(*values):
50 def _get_single_namespace(x):
51 if hasattr(x, "__array_namespace__"):
52 return x.__array_namespace__()
53 elif isinstance(x, array_type("cupy")):
54 # cupy is fully compliant from xarray's perspective, but will not expose
55 # __array_namespace__ until at least v14. Special case it for now
56 import cupy as cp
57
58 return cp
59 else:
60 return np
61
62 namespaces = {_get_single_namespace(t) for t in values}
63 non_numpy = namespaces - {np}

Callers 1

get_array_namespaceFunction · 0.85

Calls 2

array_typeFunction · 0.90
__array_namespace__Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…