Skip to content

concatenate

Concatenate the input arrays along the given dimension.

Parameters:

Name Type Description Default
arrays Iterable[SparseArray]

The input arrays to concatenate.

required
axis int

The axis along which to concatenate the input arrays. The default is zero.

0
compressed_axes iterable

The axes to compress if returning a GCXS array.

None

Returns:

Type Description
SparseArray

The output concatenated array.

Raises:

Type Description
ValueError

If all elements of arrays don't have the same fill-value.

See Also

numpy.concatenate : NumPy equivalent function

Source code in sparse/numba_backend/_common.py
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
def concatenate(arrays, axis=0, compressed_axes=None):
    """
    Concatenate the input arrays along the given dimension.

    Parameters
    ----------
    arrays : Iterable[SparseArray]
        The input arrays to concatenate.
    axis : int, optional
        The axis along which to concatenate the input arrays. The default is zero.
    compressed_axes : iterable, optional
        The axes to compress if returning a GCXS array.

    Returns
    -------
    SparseArray
        The output concatenated array.

    Raises
    ------
    ValueError
        If all elements of `arrays` don't have the same fill-value.

    See Also
    --------
    [`numpy.concatenate`][] : NumPy equivalent function
    """
    from ._compressed import GCXS

    if not builtins.all(isinstance(arr, GCXS) for arr in arrays):
        from ._coo import concatenate as coo_concat

        return coo_concat(arrays, axis)

    from ._compressed import concatenate as gcxs_concat

    return gcxs_concat(arrays, axis, compressed_axes)