Skip to content

argmin

Returns the indices of the minimum values along a specified axis. When the minimum value occurs multiple times, only the indices corresponding to the first occurrence are returned.

Parameters:

Name Type Description Default
x SparseArray

Input array. The fill value must be 0.0 and all non-zero values must be less than 0.0.

required
axis int

Axis along which to search. If None, the function must return the index of the minimum value of the flattened array. Default: None.

None
keepdims bool_

If True, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array. Otherwise, if False, the reduced axes (dimensions) must not be included in the result. Default: False.

False

Returns:

Name Type Description
out ndarray

If axis is None, a zero-dimensional array containing the index of the first occurrence of the minimum value. Otherwise, a non-zero-dimensional array containing the indices of the minimum values.

Source code in sparse/numba_backend/_coo/common.py
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
def argmin(x, /, *, axis=None, keepdims=False):
    """
    Returns the indices of the minimum values along a specified axis.
    When the minimum value occurs multiple times, only the indices
    corresponding to the first occurrence are returned.

    Parameters
    ----------
    x : SparseArray
        Input array. The fill value must be ``0.0`` and all non-zero values
        must be less than ``0.0``.
    axis : int, optional
        Axis along which to search. If ``None``, the function must return
        the index of the minimum value of the flattened array. Default: ``None``.
    keepdims : bool, optional
        If ``True``, the reduced axes (dimensions) must be included in the result
        as singleton dimensions, and, accordingly, the result must be compatible
        with the input array. Otherwise, if ``False``, the reduced axes (dimensions)
        must not be included in the result. Default: ``False``.

    Returns
    -------
    out : numpy.ndarray
        If ``axis`` is ``None``, a zero-dimensional array containing the index of
        the first occurrence of the minimum value. Otherwise, a non-zero-dimensional
        array containing the indices of the minimum values.
    """
    return _arg_minmax_common(x, axis=axis, keepdims=keepdims, mode="min")