def is_simple_coords()

in bayesmark/xr_util.py [0:0]


def is_simple_coords(coords, min_side=0, dims=None):
    """Check if all xr coordinates are "simple". That is, equals to ``np.arange(n)``.

    Parameters
    ----------
    coords : dict-like of coordinates
        The coordinates we would like to check, e.g. from ``DataArray.coords``.
    min_side : int
        The minimum side requirement. We can set this ``min_side=1`` and have empty coordinates result in a return
        value of ``False``.
    dims : None or list of dimension names
        Dimensions we want to check for simplicity. If ``None``, check all dimensions.

    Returns
    -------
    simple : bool
        True when all coordinates are simple.
    """
    for kk in coords:
        if (dims is None) or (kk in dims):
            C = coords[kk].values
            # Not checking dtype on empty coords, could check that too if we want to be strict
            if len(C) > 0 and C.dtype != np.int_:
                return False

            C = C.tolist()
            if len(C) < min_side:
                return False
            if C != list(range(len(C))):
                return False
    return True