def xr_coords()

in hypothesis_gufunc/extra/xr.py [0:0]


def xr_coords(elements=None, min_side=0, max_side=DEFAULT_SIDE, unique=True):
    """Generate values for the coordinates in a :class:`xarray:xarray.DataArray`.

    Non-unique coords do not make much sense, but xarray allows it. So we should be able to generate it.

    Parameters
    ----------
    elements : SearchStrategy or None
        Strategy to fill the elements of coordinates. Uses :func:`hypothesis:hypothesis.strategies.integers` by default.
    min_side : int
        Minimum length of coordinates array.
    max_side : int or None
        Maximum length of coordinates array.
    unique : bool
        If all coordinate values should be unique. `xarray` allows non-unique values, but it makes no sense.

    Returns
    -------
    L : list
        The coordinates filled with samples from `elements`.
    """
    _check_valid_size_interval(min_side, max_side, "side")

    if elements is None:
        elements = integers()

    S = lists(elements=elements, min_size=min_side, max_size=max_side, unique=unique)
    return S