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

Function asarray

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

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