MCPcopy
hub / github.com/dask/dask / asarray

Function asarray

dask/array/core.py:4855–4933  ·  view source on GitHub ↗

Convert the input to a dask array. 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 tuples, tuples of lists and ndarrays. allow_unknown_chunksizes: bool

(
    a, allow_unknown_chunksizes=False, dtype=None, order=None, *, like=None, **kwargs
)

Source from the content-addressed store, hash-verified

4853
4854
4855def asarray(
4856 a, allow_unknown_chunksizes=False, dtype=None, order=None, *, like=None, **kwargs
4857):
4858 """Convert the input to a dask array.
4859
4860 Parameters
4861 ----------
4862 a : array-like
4863 Input data, in any form that can be converted to a dask array. This
4864 includes lists, lists of tuples, tuples, tuples of tuples, tuples of
4865 lists and ndarrays.
4866 allow_unknown_chunksizes: bool
4867 Allow unknown chunksizes, such as come from converting from dask
4868 dataframes. Dask.array is unable to verify that chunks line up. If
4869 data comes from differently aligned sources then this can cause
4870 unexpected results.
4871 dtype : data-type, optional
4872 By default, the data-type is inferred from the input data.
4873 order : {‘C’, ‘F’, ‘A’, ‘K’}, optional
4874 Memory layout. ‘A’ and ‘K’ depend on the order of input array a.
4875 ‘C’ row-major (C-style), ‘F’ column-major (Fortran-style) memory
4876 representation. ‘A’ (any) means ‘F’ if a is Fortran contiguous, ‘C’
4877 otherwise ‘K’ (keep) preserve input order. Defaults to ‘C’.
4878 like: array-like
4879 Reference object to allow the creation of Dask arrays with chunks
4880 that are not NumPy arrays. If an array-like passed in as ``like``
4881 supports the ``__array_function__`` protocol, the chunk type of the
4882 resulting array will be defined by it. In this case, it ensures the
4883 creation of a Dask array compatible with that passed in via this
4884 argument. If ``like`` is a Dask array, the chunk type of the
4885 resulting array will be defined by the chunk type of ``like``.
4886 Requires NumPy 1.20.0 or higher.
4887
4888 Returns
4889 -------
4890 out : dask array
4891 Dask array interpretation of a.
4892
4893 Examples
4894 --------
4895 >>> import dask.array as da
4896 >>> import numpy as np
4897 >>> x = np.arange(3)
4898 >>> da.asarray(x)
4899 dask.array<array, shape=(3,), dtype=int64, chunksize=(3,), chunktype=numpy.ndarray>
4900
4901 >>> y = [[1, 2, 3], [4, 5, 6]]
4902 >>> da.asarray(y)
4903 dask.array<array, shape=(2, 3), dtype=int64, chunksize=(2, 3), chunktype=numpy.ndarray>
4904
4905 .. warning::
4906 `order` is ignored if `a` is an `Array`, has the attribute ``to_dask_array``,
4907 or is a list or tuple of `Array`&#x27;s.
4908 """
4909 if like is None:
4910 if isinstance(a, Array):
4911 return _as_dtype(a, dtype)
4912 elif hasattr(a, "to_dask_array"):

Callers 15

apply_gufuncFunction · 0.90
funcFunction · 0.90
parse_einsum_inputFunction · 0.90
_choice_validate_paramsFunction · 0.90
arrayFunction · 0.90
apply_along_axisFunction · 0.90
apply_over_axesFunction · 0.90
diffFunction · 0.90
ediff1dFunction · 0.90
gradientFunction · 0.90
searchsortedFunction · 0.90
histogramFunction · 0.90

Calls 9

anyFunction · 0.90
meta_from_arrayFunction · 0.90
asarray_safeFunction · 0.90
to_dask_arrayMethod · 0.80
splitMethod · 0.80
_as_dtypeFunction · 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…