Convert the input to a dask array. Parameters ---------- a : array-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. allow_unknown_chunksizes: bool
(
a, allow_unknown_chunksizes=False, dtype=None, order=None, *, like=None, **kwargs
)
| 1203 | |
| 1204 | |
| 1205 | def asarray( |
| 1206 | a, allow_unknown_chunksizes=False, dtype=None, order=None, *, like=None, **kwargs |
| 1207 | ): |
| 1208 | """Convert the input to a dask array. |
| 1209 | |
| 1210 | Parameters |
| 1211 | ---------- |
| 1212 | a : array-like |
| 1213 | Input data, in any form that can be converted to a dask array. This |
| 1214 | includes lists, lists of tuples, tuples, tuples of tuples, tuples of |
| 1215 | lists and ndarrays. |
| 1216 | allow_unknown_chunksizes: bool |
| 1217 | Allow unknown chunksizes, such as come from converting from dask |
| 1218 | dataframes. Dask.array is unable to verify that chunks line up. If |
| 1219 | data comes from differently aligned sources then this can cause |
| 1220 | unexpected results. |
| 1221 | dtype : data-type, optional |
| 1222 | By default, the data-type is inferred from the input data. |
| 1223 | order : {‘C’, ‘F’, ‘A’, ‘K’}, optional |
| 1224 | Memory layout. ‘A’ and ‘K’ depend on the order of input array a. |
| 1225 | ‘C’ row-major (C-style), ‘F’ column-major (Fortran-style) memory |
| 1226 | representation. ‘A’ (any) means ‘F’ if a is Fortran contiguous, ‘C’ |
| 1227 | otherwise ‘K’ (keep) preserve input order. Defaults to ‘C’. |
| 1228 | like: array-like |
| 1229 | Reference object to allow the creation of Dask arrays with chunks |
| 1230 | that are not NumPy arrays. If an array-like passed in as ``like`` |
| 1231 | supports the ``__array_function__`` protocol, the chunk type of the |
| 1232 | resulting array will be defined by it. In this case, it ensures the |
| 1233 | creation of a Dask array compatible with that passed in via this |
| 1234 | argument. If ``like`` is a Dask array, the chunk type of the |
| 1235 | resulting array will be defined by the chunk type of ``like``. |
| 1236 | Requires NumPy 1.20.0 or higher. |
| 1237 | |
| 1238 | Returns |
| 1239 | ------- |
| 1240 | out : dask array |
| 1241 | Dask array interpretation of a. |
| 1242 | |
| 1243 | Examples |
| 1244 | -------- |
| 1245 | >>> import dask.array as da |
| 1246 | >>> import numpy as np |
| 1247 | >>> x = np.arange(3) |
| 1248 | >>> da.asarray(x) |
| 1249 | dask.array<array, shape=(3,), dtype=int64, chunksize=(3,), chunktype=numpy.ndarray> |
| 1250 | |
| 1251 | >>> y = [[1, 2, 3], [4, 5, 6]] |
| 1252 | >>> da.asarray(y) |
| 1253 | dask.array<array, shape=(2, 3), dtype=int64, chunksize=(2, 3), chunktype=numpy.ndarray> |
| 1254 | |
| 1255 | .. warning:: |
| 1256 | `order` is ignored if `a` is an `Array`, has the attribute ``to_dask_array``, |
| 1257 | or is a list or tuple of `Array`'s. |
| 1258 | """ |
| 1259 | if like is None: |
| 1260 | if isinstance(a, Array): |
| 1261 | return _as_dtype(a, dtype) |
| 1262 | elif hasattr(a, "to_dask_array"): |
searching dependent graphs…