Skip to content

intervals_chain

intervals_chain(X, binding, chain_mode)

Compute an intervals chain from a masked 1-D sequence.

Masked (missing) values in X are skipped; intervals are computed over the compressed sequence of unmasked elements only.

Parameters:

Name Type Description Default

X

masked_array

1-D masked array. Masked positions are treated as absent elements.

required

binding

int

binding.start or binding.end.

required

chain_mode

int

chain_mode.boundary or chain_mode.cycle.

required

Returns:

Type Description
ndarray

Plain 1-D integer array (same as :func:foapy.core.intervals_chain applied to the compressed, unmasked sub-sequence).

Raises:

Type Description
Not1DArrayException

When the underlying compressed sequence is not 1-dimensional.

ValueError

When binding or chain_mode is invalid.

Source code in .tox/docs-deploy/lib/python3.11/site-packages/foapy/ma/_intervals_chain.py
def intervals_chain(X, binding: int, chain_mode: int):
    """
    Compute an intervals chain from a masked 1-D sequence.

    Masked (missing) values in *X* are skipped; intervals are computed over
    the compressed sequence of unmasked elements only.

    Parameters
    ----------
    X : masked_array
        1-D masked array.  Masked positions are treated as absent elements.
    binding : int
        ``binding.start`` or ``binding.end``.
    chain_mode : int
        ``chain_mode.boundary`` or ``chain_mode.cycle``.

    Returns
    -------
    ndarray
        Plain 1-D integer array (same as :func:`foapy.core.intervals_chain`
        applied to the compressed, unmasked sub-sequence).

    Raises
    ------
    Not1DArrayException
        When the underlying compressed sequence is not 1-dimensional.
    ValueError
        When ``binding`` or ``chain_mode`` is invalid.
    """
    ar = ma.asarray(X)
    compressed = ar.compressed()
    return core_intervals_chain(compressed, binding, chain_mode)