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)
| 501 | |
| 502 | |
| 503 | def 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 | |
| 517 | def asanyarray_safe(a, like, **kwargs): |
no test coverage detected