Skip to content

min

Calculates the minimum value of the input array x.

Parameters:

Name Type Description Default
x

input array. Should have a real-valued data type.

required
axis

axis or axes along which minimum values are computed. By default, the minimum value must be computed over the entire array. If a tuple of integers, minimum values must be computed over multiple axes. Default: None.

None
keepdims

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

False

Returns:

Name Type Description
out array

if the minimum value was computed over the entire array, a zero-dimensional array containing the minimum value. Otherwise, a non-zero-dimensional array containing the minimum values. The returned array must have the same data type as x.

Special Cases

For floating-point operands, if x_i is NaN, the minimum value is NaN (i.e., NaN values propagate).

Examples:

>>> a = sparse.COO.from_numpy(np.array([[0, -1], [-2, 0]]))
>>> o = sparse.min(a, axis=1)
>>> o.todense()
array([-1, -2])
Source code in sparse/numba_backend/_common.py
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
def min(x, /, *, axis=None, keepdims=False):
    """
    Calculates the minimum value of the input array ``x``.

    Parameters
    ----------
    x: array
        input array. Should have a real-valued data type.
    axis: Optional[Union[int, Tuple[int, ...]]]
        axis or axes along which minimum values are computed.
        By default, the minimum value must be computed over the entire array.
        If a tuple of integers, minimum values must be computed over multiple axes. Default: ``None``.
    keepdims: bool
        If ``True``, the reduced axes (dimensions) are included in the result as singleton dimensions.
        Accordingly, the result must be compatible with the input array.
        Otherwise, if ``False``, the reduced axes (dimensions) are not be included in the result. Default: ``False``.

    Returns
    -------
    out: array
        if the minimum value was computed over the entire array, a zero-dimensional array containing the minimum value.
        Otherwise, a non-zero-dimensional array containing the minimum values.
        The returned array must have the same data type as ``x``.

    Special Cases
    -------------
    For floating-point operands, if ``x_i`` is ``NaN``, the minimum value is ``NaN`` (i.e., ``NaN`` values propagate).

    Examples
    --------
    >>> a = sparse.COO.from_numpy(np.array([[0, -1], [-2, 0]]))
    >>> o = sparse.min(a, axis=1)
    >>> o.todense()
    array([-1, -2])
    """
    return x.min(axis=axis, keepdims=keepdims)