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

Function _walk_array_namespaces

xarray/ufuncs.py:12–29  ·  view source on GitHub ↗
(obj, namespaces)

Source from the content-addressed store, hash-verified

10
11
12def _walk_array_namespaces(obj, namespaces):
13 if isinstance(obj, xr.DataTree):
14 # TODO: DataTree doesn't actually support ufuncs yet
15 for node in obj.subtree:
16 _walk_array_namespaces(node.dataset, namespaces)
17 elif isinstance(obj, xr.Dataset):
18 for name in obj.data_vars:
19 _walk_array_namespaces(obj[name], namespaces)
20 elif isinstance(obj, GroupBy):
21 _walk_array_namespaces(next(iter(obj))[1], namespaces)
22 elif isinstance(obj, xr.DataArray | xr.Variable):
23 _walk_array_namespaces(obj.data, namespaces)
24 else:
25 namespace = getattr(obj, "__array_namespace__", None)
26 if namespace is not None:
27 namespaces.add(namespace())
28
29 return namespaces
30
31
32def get_array_namespace(*args):

Callers 1

get_array_namespaceFunction · 0.85

Calls 1

addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…