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

Function asarray_safe

dask/array/utils.py:503–514  ·  view source on GitHub ↗

If a is dask.array, return dask.array.asarray(a, **kwargs), otherwise return np.asarray(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="sync

(a, like, **kwargs)

Source from the content-addressed store, hash-verified

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

Callers 15

takeFunction · 0.90
asarrayFunction · 0.90
_nanmin_skipFunction · 0.90
_nanmax_skipFunction · 0.90
arg_reductionFunction · 0.90
quantileFunction · 0.90
nanquantileFunction · 0.90
_choice_validate_paramsFunction · 0.90
diffFunction · 0.90
digitizeFunction · 0.90
trilFunction · 0.90

Calls 1

_array_like_safeFunction · 0.85

Tested by

no test coverage detected