MCPcopy Create free account
hub / github.com/dask/dask / asanyarray

Function asanyarray

dask/array/core.py:4931–5011  ·  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

4929
4930
4931def asanyarray(a, dtype=None, order=None, *, like=None, inline_array=False):
4932 """Convert the input to a dask array.
4933
4934 Subclasses of ``np.ndarray`` will be passed through as chunks unchanged.
4935
4936 Parameters
4937 ----------
4938 a : array-like
4939 Input data, in any form that can be converted to a dask array. This
4940 includes lists, lists of tuples, tuples, tuples of tuples, tuples of
4941 lists and ndarrays.
4942 dtype : data-type, optional
4943 By default, the data-type is inferred from the input data.
4944 order : {‘C’, ‘F’, ‘A’, ‘K’}, optional
4945 Memory layout. ‘A’ and ‘K’ depend on the order of input array a.
4946 ‘C’ row-major (C-style), ‘F’ column-major (Fortran-style) memory
4947 representation. ‘A’ (any) means ‘F’ if a is Fortran contiguous, ‘C’
4948 otherwise ‘K’ (keep) preserve input order. Defaults to ‘C’.
4949 like: array-like
4950 Reference object to allow the creation of Dask arrays with chunks
4951 that are not NumPy arrays. If an array-like passed in as ``like``
4952 supports the ``__array_function__`` protocol, the chunk type of the
4953 resulting array will be defined by it. In this case, it ensures the
4954 creation of a Dask array compatible with that passed in via this
4955 argument. If ``like`` is a Dask array, the chunk type of the
4956 resulting array will be defined by the chunk type of ``like``.
4957 Requires NumPy 1.20.0 or higher.
4958 inline_array:
4959 Whether to inline the array in the resulting dask graph. For more information,
4960 see the documentation for ``dask.array.from_array()``.
4961
4962 Returns
4963 -------
4964 out : dask array
4965 Dask array interpretation of a.
4966
4967 Examples
4968 --------
4969 >>> import dask.array as da
4970 >>> import numpy as np
4971 >>> x = np.arange(3)
4972 >>> da.asanyarray(x)
4973 dask.array<array, shape=(3,), dtype=int64, chunksize=(3,), chunktype=numpy.ndarray>
4974
4975 >>> y = [[1, 2, 3], [4, 5, 6]]
4976 >>> da.asanyarray(y)
4977 dask.array<array, shape=(2, 3), dtype=int64, chunksize=(2, 3), chunktype=numpy.ndarray>
4978
4979 .. warning::
4980 `order` is ignored if `a` is an `Array`, has the attribute ``to_dask_array``,
4981 or is a list or tuple of `Array`&#x27;s.
4982 """
4983 if like is None:
4984 if isinstance(a, Array):
4985 return _as_dtype(a, dtype)
4986 elif hasattr(a, "to_dask_array"):
4987 return _as_dtype(a.to_dask_array(), dtype)
4988 elif type(a).__module__.split(".")[0] == "xarray" and hasattr(a, "data"):

Callers 15

reductionFunction · 0.90
filledFunction · 0.90
_Function · 0.90
masked_equalFunction · 0.90
masked_invalidFunction · 0.90
masked_insideFunction · 0.90
masked_outsideFunction · 0.90
masked_whereFunction · 0.90
masked_valuesFunction · 0.90
fix_invalidFunction · 0.90
getdataFunction · 0.90
getmaskarrayFunction · 0.90

Calls 10

anyFunction · 0.90
meta_from_arrayFunction · 0.90
asanyarray_safeFunction · 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