Skip to content

nanmin

Minimize along the given axes, skipping NaN values. Uses all axes by default.

Parameters:

Name Type Description Default
x SparseArray

The array to perform the reduction on.

required
axis Union[int, Iterable[int]]

The axes along which to minimize. Uses all axes by default.

None
keepdims bool_

Whether or not to keep the dimensions of the original array.

False
dtype dtype

The data type of the output array.

None

Returns:

Type Description
COO

The reduced output sparse array.

See Also
Source code in sparse/numba_backend/_coo/common.py
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
def nanmin(x, axis=None, keepdims=False, dtype=None, out=None):
    """
    Minimize along the given axes, skipping ``NaN`` values. Uses all axes by default.

    Parameters
    ----------
    x : SparseArray
        The array to perform the reduction on.
    axis : Union[int, Iterable[int]], optional
        The axes along which to minimize. Uses all axes by default.
    keepdims : bool, optional
        Whether or not to keep the dimensions of the original array.
    dtype : numpy.dtype
        The data type of the output array.

    Returns
    -------
    COO
        The reduced output sparse array.

    See Also
    --------
    - [`sparse.COO.min`][] : Function without `NaN` skipping.
    - [`numpy.nanmin`][] : Equivalent Numpy function.
    """
    assert out is None
    x = asCOO(x, name="nanmin")

    ar = x.reduce(np.fmin, axis=axis, keepdims=keepdims, dtype=dtype)

    if (isscalar(ar) and np.isnan(ar)) or np.isnan(ar.data).any():
        warnings.warn("All-NaN slice encountered", RuntimeWarning, stacklevel=1)

    return ar