Skip to content

squeeze

Remove singleton dimensions from array.

Parameters:

Name Type Description Default
x SparseArray

Input array.

required
axis int or tuple[int, ...]

The singleton axes to remove. By default all singleton axes are removed.

None

Returns:

Name Type Description
output SparseArray

Array with singleton dimensions removed.

Source code in sparse/numba_backend/_common.py
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
@_support_numpy
def squeeze(x, /, axis=None):
    """Remove singleton dimensions from array.

    Parameters
    ----------
    x : SparseArray
        Input array.
    axis : int or tuple[int, ...], optional
        The singleton axes to remove. By default all singleton axes are removed.

    Returns
    -------
    output : SparseArray
        Array with singleton dimensions removed.
    """
    return x.squeeze(axis=axis)