dask.array.asanyarray

dask.array.asanyarray

dask.array.asanyarray(a, dtype=None, order=None, *, like=None, inline_array=False)[source]

Convert the input to a dask array.

Subclasses of np.ndarray will be passed through as chunks unchanged.

Parameters
aarray-like

Input data, in any form that can be converted to a dask array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.

dtypedata-type, optional

By default, the data-type is inferred from the input data.

order{‘C’, ‘F’, ‘A’, ‘K’}, optional

Memory layout. ‘A’ and ‘K’ depend on the order of input array a. ‘C’ row-major (C-style), ‘F’ column-major (Fortran-style) memory representation. ‘A’ (any) means ‘F’ if a is Fortran contiguous, ‘C’ otherwise ‘K’ (keep) preserve input order. Defaults to ‘C’.

like: array-like

Reference object to allow the creation of Dask arrays with chunks that are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the chunk type of the resulting array will be defined by it. In this case, it ensures the creation of a Dask array compatible with that passed in via this argument. If like is a Dask array, the chunk type of the resulting array will be defined by the chunk type of like. Requires NumPy 1.20.0 or higher.

inline_array:

Whether to inline the array in the resulting dask graph. For more information, see the documentation for dask.array.from_array().

Returns
outdask array

Dask array interpretation of a.

Examples

>>> import dask.array as da
>>> import numpy as np
>>> x = np.arange(3)
>>> da.asanyarray(x)
dask.array<array, shape=(3,), dtype=int64, chunksize=(3,), chunktype=numpy.ndarray>
>>> y = [[1, 2, 3], [4, 5, 6]]
>>> da.asanyarray(y)
dask.array<array, shape=(2, 3), dtype=int64, chunksize=(2, 3), chunktype=numpy.ndarray>