MCPcopy Create free account
hub / github.com/dask/dask / asanyarray_safe

Function asanyarray_safe

dask/array/utils.py:517–528  ·  view source on GitHub ↗

If a is dask.array, return dask.array.asanyarray(a, **kwargs), otherwise return np.asanyarray(a, like=like, **kwargs), dispatching the call to the library that implements the like array. Note that when a is a dask.Array but like isn't, this function will call a.compute(scheduler

(a, like, **kwargs)

Source from the content-addressed store, hash-verified

515
516
517def asanyarray_safe(a, like, **kwargs):
518 """
519 If a is dask.array, return dask.array.asanyarray(a, **kwargs),
520 otherwise return np.asanyarray(a, like=like, **kwargs), dispatching
521 the call to the library that implements the like array. Note that
522 when a is a dask.Array but like isn't, this function will call
523 a.compute(scheduler="sync") before np.asanyarray, as downstream
524 libraries are unlikely to know how to convert a dask.Array.
525 """
526 from dask.array.core import asanyarray
527
528 return _array_like_safe(np.asanyarray, asanyarray, a, like, **kwargs)
529
530
531def validate_axis(axis, ndim):

Callers 2

sanitize_indexFunction · 0.90
asanyarrayFunction · 0.90

Calls 1

_array_like_safeFunction · 0.85

Tested by

no test coverage detected