MCPcopy Index your code
hub / github.com/dask/dask / asanyarray

Function asanyarray

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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…