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

Function asanyarray

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

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