def decimal_to_ratio(d):
    """Convert Decimal d to exact integer ratio (numerator, denominator).
    """
    sign, digits, exp = d.as_tuple()
    if ('F', 'n', 'N') in exp:  # INF, NAN, sNAN
        assert not d.is_finite()
        raise ValueError
    num = 0
    for digit in digits:
        num = num * 10 + digit
    if sign:
        num = -num
    den = 10 ** -exp
    return (num, den)
dataset/ETHPy150Open avalente/appmetrics/appmetrics/statistics.py/decimal_to_ratio/swapped operands of `in`