MCPcopy
hub / github.com/dask/dask / asanyarray

Function asanyarray

dask/array/_array_expr/_collection.py:1283–1360  ·  view source on GitHub ↗

Convert the input to a dask array. Subclasses of ``np.ndarray`` will be passed through as chunks unchanged. 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 tu

(a, dtype=None, order=None, *, like=None, inline_array=False)

Source from the content-addressed store, hash-verified

1281
1282
1283def asanyarray(a, dtype=None, order=None, *, like=None, inline_array=False):
1284 """Convert the input to a dask array.
1285
1286 Subclasses of ``np.ndarray`` will be passed through as chunks unchanged.
1287
1288 Parameters
1289 ----------
1290 a : array-like
1291 Input data, in any form that can be converted to a dask array. This
1292 includes lists, lists of tuples, tuples, tuples of tuples, tuples of
1293 lists and ndarrays.
1294 dtype : data-type, optional
1295 By default, the data-type is inferred from the input data.
1296 order : {‘C’, ‘F’, ‘A’, ‘K’}, optional
1297 Memory layout. ‘A’ and ‘K’ depend on the order of input array a.
1298 ‘C’ row-major (C-style), ‘F’ column-major (Fortran-style) memory
1299 representation. ‘A’ (any) means ‘F’ if a is Fortran contiguous, ‘C’
1300 otherwise ‘K’ (keep) preserve input order. Defaults to ‘C’.
1301 like: array-like
1302 Reference object to allow the creation of Dask arrays with chunks
1303 that are not NumPy arrays. If an array-like passed in as ``like``
1304 supports the ``__array_function__`` protocol, the chunk type of the
1305 resulting array will be defined by it. In this case, it ensures the
1306 creation of a Dask array compatible with that passed in via this
1307 argument. If ``like`` is a Dask array, the chunk type of the
1308 resulting array will be defined by the chunk type of ``like``.
1309 Requires NumPy 1.20.0 or higher.
1310 inline_array:
1311 Whether to inline the array in the resulting dask graph. For more information,
1312 see the documentation for ``dask.array.from_array()``.
1313
1314 Returns
1315 -------
1316 out : dask array
1317 Dask array interpretation of a.
1318
1319 Examples
1320 --------
1321 >>> import dask.array as da
1322 >>> import numpy as np
1323 >>> x = np.arange(3)
1324 >>> da.asanyarray(x)
1325 dask.array<array, shape=(3,), dtype=int64, chunksize=(3,), chunktype=numpy.ndarray>
1326
1327 >>> y = [[1, 2, 3], [4, 5, 6]]
1328 >>> da.asanyarray(y)
1329 dask.array<array, shape=(2, 3), dtype=int64, chunksize=(2, 3), chunktype=numpy.ndarray>
1330
1331 .. warning::
1332 `order` is ignored if `a` is an `Array`, has the attribute ``to_dask_array``,
1333 or is a list or tuple of `Array`&#x27;s.
1334 """
1335 if like is None:
1336 if isinstance(a, Array):
1337 return _as_dtype(a, dtype)
1338 elif hasattr(a, "to_dask_array"):
1339 return _as_dtype(a.to_dask_array(), dtype)
1340 elif type(a).__module__.split(".")[0] == "xarray" and hasattr(a, "data"):

Callers 1

elemwiseFunction · 0.70

Calls 9

anyFunction · 0.90
meta_from_arrayFunction · 0.90
to_dask_arrayMethod · 0.80
splitMethod · 0.80
_as_dtypeFunction · 0.70
asarrayFunction · 0.70
stackFunction · 0.70
from_arrayFunction · 0.70
map_blocksMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…