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)
| 4732 | |
| 4733 | |
| 4734 | def asanyarray(a, dtype=None, order=None, *, like=None, inline_array=False): |
| 4735 | """Convert the input to a dask array. |
| 4736 | |
| 4737 | Subclasses of ``np.ndarray`` will be passed through as chunks unchanged. |
| 4738 | |
| 4739 | Parameters |
| 4740 | ---------- |
| 4741 | a : array-like |
| 4742 | Input data, in any form that can be converted to a dask array. This |
| 4743 | includes lists, lists of tuples, tuples, tuples of tuples, tuples of |
| 4744 | lists and ndarrays. |
| 4745 | dtype : data-type, optional |
| 4746 | By default, the data-type is inferred from the input data. |
| 4747 | order : {‘C’, ‘F’, ‘A’, ‘K’}, optional |
| 4748 | Memory layout. ‘A’ and ‘K’ depend on the order of input array a. |
| 4749 | ‘C’ row-major (C-style), ‘F’ column-major (Fortran-style) memory |
| 4750 | representation. ‘A’ (any) means ‘F’ if a is Fortran contiguous, ‘C’ |
| 4751 | otherwise ‘K’ (keep) preserve input order. Defaults to ‘C’. |
| 4752 | like: array-like |
| 4753 | Reference object to allow the creation of Dask arrays with chunks |
| 4754 | that are not NumPy arrays. If an array-like passed in as ``like`` |
| 4755 | supports the ``__array_function__`` protocol, the chunk type of the |
| 4756 | resulting array will be defined by it. In this case, it ensures the |
| 4757 | creation of a Dask array compatible with that passed in via this |
| 4758 | argument. If ``like`` is a Dask array, the chunk type of the |
| 4759 | resulting array will be defined by the chunk type of ``like``. |
| 4760 | Requires NumPy 1.20.0 or higher. |
| 4761 | inline_array: |
| 4762 | Whether to inline the array in the resulting dask graph. For more information, |
| 4763 | see the documentation for ``dask.array.from_array()``. |
| 4764 | |
| 4765 | Returns |
| 4766 | ------- |
| 4767 | out : dask array |
| 4768 | Dask array interpretation of a. |
| 4769 | |
| 4770 | Examples |
| 4771 | -------- |
| 4772 | >>> import dask.array as da |
| 4773 | >>> import numpy as np |
| 4774 | >>> x = np.arange(3) |
| 4775 | >>> da.asanyarray(x) |
| 4776 | dask.array<array, shape=(3,), dtype=int64, chunksize=(3,), chunktype=numpy.ndarray> |
| 4777 | |
| 4778 | >>> y = [[1, 2, 3], [4, 5, 6]] |
| 4779 | >>> da.asanyarray(y) |
| 4780 | dask.array<array, shape=(2, 3), dtype=int64, chunksize=(2, 3), chunktype=numpy.ndarray> |
| 4781 | |
| 4782 | .. warning:: |
| 4783 | `order` is ignored if `a` is an `Array`, has the attribute ``to_dask_array``, |
| 4784 | or is a list or tuple of `Array`'s. |
| 4785 | """ |
| 4786 | if like is None: |
| 4787 | if isinstance(a, Array): |
| 4788 | return _as_dtype(a, dtype) |
| 4789 | elif hasattr(a, "to_dask_array"): |
| 4790 | return _as_dtype(a.to_dask_array(), dtype) |
| 4791 | elif type(a).__module__.split(".")[0] == "xarray" and hasattr(a, "data"): |
no test coverage detected