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)
| 484 | |
| 485 | |
| 486 | def asarray_safe(a, like, **kwargs): |
| 487 | """ |
| 488 | If a is dask.array, return dask.array.asarray(a, **kwargs), |
| 489 | otherwise return np.asarray(a, like=like, **kwargs), dispatching |
| 490 | the call to the library that implements the like array. Note that |
| 491 | when a is a dask.Array but like isn't, this function will call |
| 492 | a.compute(scheduler="sync") before np.asarray, as downstream |
| 493 | libraries are unlikely to know how to convert a dask.Array. |
| 494 | """ |
| 495 | from dask.array.core import asarray |
| 496 | |
| 497 | return _array_like_safe(np.asarray, asarray, a, like, **kwargs) |
| 498 | |
| 499 | |
| 500 | def asanyarray_safe(a, like, **kwargs): |
no test coverage detected
searching dependent graphs…