def xr_coords_dicts()

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


def xr_coords_dicts(dims, elements=None, min_side=0, max_side=DEFAULT_SIDE, unique_coords=True, coords_st={}):
    """Build a dictionary of coordinates for the purpose of building a :class:`xarray:xarray.DataArray`.

    `xarray` allows some dims to not have any specified coordinate. This strategy assigns a coord to every dimension. If
    we really want to test those possibilities we need to take a subset of the `dict` that is sampled from this
    strategy.

    Parameters
    ----------
    dims : list(str)
        Dimensions we need to generate coordinates for.
    elements : SearchStrategy or None
        Strategy to fill the elements of coordinates. Uses `integers` by default.
    min_side : int
        Minimum length of coordinates array.
    max_side : int or None
        Maximum length of coordinates array.
    unique_coords : bool
        If all coordinate values should be unique. `xarray` allows non-unique values, but it makes no sense.
    coords_st : dict(str, SearchStrategy)
        Special strategies for filling specific dimensions. Use the dimension name as the key and the strategy for
        generating the coordinate as the value.

    Returns
    -------
    coords : dict(str, list)
        Dictionary mapping dimension name to its coordinate values (a list with elements from the `elements` strategy).
    """
    _check_valid_size_interval(min_side, max_side, "side")

    default_st = xr_coords(elements=elements, min_side=min_side, max_side=max_side, unique=unique_coords)
    C = OrderedDict([(dd, coords_st.get(dd, default_st)) for dd in dims])
    S = fixed_dictionaries(C)
    return S