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

Function asarray

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

4651
4652
4653def asarray(
4654 a, allow_unknown_chunksizes=False, dtype=None, order=None, *, like=None, **kwargs
4655):
4656 """Convert the input to a dask array.
4657
4658 Parameters
4659 ----------
4660 a : array-like
4661 Input data, in any form that can be converted to a dask array. This
4662 includes lists, lists of tuples, tuples, tuples of tuples, tuples of
4663 lists and ndarrays.
4664 allow_unknown_chunksizes: bool
4665 Allow unknown chunksizes, such as come from converting from dask
4666 dataframes. Dask.array is unable to verify that chunks line up. If
4667 data comes from differently aligned sources then this can cause
4668 unexpected results.
4669 dtype : data-type, optional
4670 By default, the data-type is inferred from the input data.
4671 order : {‘C’, ‘F’, ‘A’, ‘K’}, optional
4672 Memory layout. ‘A’ and ‘K’ depend on the order of input array a.
4673 ‘C’ row-major (C-style), ‘F’ column-major (Fortran-style) memory
4674 representation. ‘A’ (any) means ‘F’ if a is Fortran contiguous, ‘C’
4675 otherwise ‘K’ (keep) preserve input order. Defaults to ‘C’.
4676 like: array-like
4677 Reference object to allow the creation of Dask arrays with chunks
4678 that are not NumPy arrays. If an array-like passed in as ``like``
4679 supports the ``__array_function__`` protocol, the chunk type of the
4680 resulting array will be defined by it. In this case, it ensures the
4681 creation of a Dask array compatible with that passed in via this
4682 argument. If ``like`` is a Dask array, the chunk type of the
4683 resulting array will be defined by the chunk type of ``like``.
4684 Requires NumPy 1.20.0 or higher.
4685
4686 Returns
4687 -------
4688 out : dask array
4689 Dask array interpretation of a.
4690
4691 Examples
4692 --------
4693 >>> import dask.array as da
4694 >>> import numpy as np
4695 >>> x = np.arange(3)
4696 >>> da.asarray(x)
4697 dask.array<array, shape=(3,), dtype=int64, chunksize=(3,), chunktype=numpy.ndarray>
4698
4699 >>> y = [[1, 2, 3], [4, 5, 6]]
4700 >>> da.asarray(y)
4701 dask.array<array, shape=(2, 3), dtype=int64, chunksize=(2, 3), chunktype=numpy.ndarray>
4702
4703 .. warning::
4704 `order` is ignored if `a` is an `Array`, has the attribute ``to_dask_array``,
4705 or is a list or tuple of `Array`&#x27;s.
4706 """
4707 if like is None:
4708 if isinstance(a, Array):
4709 return _as_dtype(a, dtype)
4710 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