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

Function asarray

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

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