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

Function concatenate

dask/array/core.py:4617–4758  ·  view source on GitHub ↗

Concatenate arrays along an existing axis Given a sequence of dask Arrays form a new dask Array by stacking them along an existing dimension (axis=0 by default) Parameters ---------- seq: list of dask.arrays axis: int Dimension along which to align all of the a

(seq, axis=0, allow_unknown_chunksizes=False)

Source from the content-addressed store, hash-verified

4615
4616
4617def concatenate(seq, axis=0, allow_unknown_chunksizes=False):
4618 """
4619 Concatenate arrays along an existing axis
4620
4621 Given a sequence of dask Arrays form a new dask Array by stacking them
4622 along an existing dimension (axis=0 by default)
4623
4624 Parameters
4625 ----------
4626 seq: list of dask.arrays
4627 axis: int
4628 Dimension along which to align all of the arrays. If axis is None,
4629 arrays are flattened before use.
4630 allow_unknown_chunksizes: bool
4631 Allow unknown chunksizes, such as come from converting from dask
4632 dataframes. Dask.array is unable to verify that chunks line up. If
4633 data comes from differently aligned sources then this can cause
4634 unexpected results.
4635
4636 Examples
4637 --------
4638
4639 Create slices
4640
4641 >>> import dask.array as da
4642 >>> import numpy as np
4643
4644 >>> data = [da.from_array(np.ones((4, 4)), chunks=(2, 2))
4645 ... for i in range(3)]
4646
4647 >>> x = da.concatenate(data, axis=0)
4648 >>> x.shape
4649 (12, 4)
4650
4651 >>> da.concatenate(data, axis=1).shape
4652 (4, 12)
4653
4654 Result is a new dask Array
4655
4656 See Also
4657 --------
4658 stack
4659 """
4660 from dask.array import wrap
4661
4662 seq = [asarray(a, allow_unknown_chunksizes=allow_unknown_chunksizes) for a in seq]
4663
4664 if not seq:
4665 raise ValueError("Need array(s) to concatenate")
4666
4667 if axis is None:
4668 seq = [a.flatten() for a in seq]
4669 axis = 0
4670
4671 seq_metas = [meta_from_array(s) for s in seq]
4672 _concatenate = concatenate_lookup.dispatch(
4673 type(max(seq_metas, key=lambda x: getattr(x, "__array_priority__", 0)))
4674 )

Callers 15

sfqrFunction · 0.90
periodicFunction · 0.90
reflectFunction · 0.90
nearestFunction · 0.90
constantFunction · 0.90
add_dummy_paddingFunction · 0.90
vstackFunction · 0.90
hstackFunction · 0.90
dstackFunction · 0.90
diffFunction · 0.90
ediff1dFunction · 0.90
covFunction · 0.90

Calls 15

meta_from_arrayFunction · 0.90
maxFunction · 0.90
sumFunction · 0.90
allFunction · 0.90
anyFunction · 0.90
_concatenateFunction · 0.85
unify_chunksFunction · 0.85
flattenMethod · 0.80
from_collectionsMethod · 0.80
asarrayFunction · 0.70
ArrayClass · 0.70
concatFunction · 0.50

Tested by 3

test_concatenateFunction · 0.72
test_concatenate_typesFunction · 0.72
test_dtype_complexFunction · 0.72