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

Function asanyarray_safe

dask/array/utils.py:502–513  ·  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

500
501
502def asanyarray_safe(a, like, **kwargs):
503 """
504 If a is dask.array, return dask.array.asanyarray(a, **kwargs),
505 otherwise return np.asanyarray(a, like=like, **kwargs), dispatching
506 the call to the library that implements the like array. Note that
507 when a is a dask.Array but like isn't, this function will call
508 a.compute(scheduler="sync") before np.asanyarray, as downstream
509 libraries are unlikely to know how to convert a dask.Array.
510 """
511 from dask.array.core import asanyarray
512
513 return _array_like_safe(np.asanyarray, asanyarray, a, like, **kwargs)
514
515
516def 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