def _wrap(x, x_min, x_max):
    """Wrap floating point values into range

    Parameters
    ----------
    x : ee.Image or ee.Number
        Values to wrap.
    x_min : float
        Minimum value in output range.
    x_max : float
        Maximum value in output range.

    Returns
    -------
    ee.Image or ee.Number

    Notes
    -----
    This formula is used to mimic the Python modulo operator.
    Javascript/EE mod operator has the same sign as the dividend,
        so negative values stay negative.
    Python mod operator has the same sign as the divisor,
        so negative values wrap to positive.

    """
    x_range = x_max - x_min
    return x.subtract(x_min).mod(x_range).add(x_range).mod(x_range).add(x_min)
    # return np.mod((x - x_min), (x_max - x_min)) + x_min