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)
| 515 | |
| 516 | |
| 517 | def 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 | |
| 531 | def validate_axis(axis, ndim): |
no test coverage detected