def get_converters_and_unit(f, unit1, unit2):
    converters = [None, None]
    if (unit2 is None):
        if (unit1 is None):
            return (converters, dimensionless_unscaled)
        changeable = 0
        unit2 = unit1
        unit1 = None
    elif (unit2 is unit1):
        return (converters, unit1)
    else:
        changeable = 1
    if (unit1 is None):
        try:
            converters[changeable] = get_converter(unit2, dimensionless_unscaled)
        except UnitsError:
            converters[(1 - changeable)] = False
            return (converters, unit2)
        else:
            return (converters, dimensionless_unscaled)
    else:
        try:
            converters[changeable] = get_converter(unit2, unit1)
        except UnitsError:
            raise UnitConversionError("Can only apply '{0}' function to quantities with compatible dimensions".format(f.__name__))
        return (converters, unit1)
def get_converters_and_unit(f, unit1, unit2):
    converters = [None, None]
    if (unit2 is None):
        if (unit1 is None):
            return (converters, dimensionless_unscaled)
        changeable = 0
        unit2 = unit1
        unit1 = None
    elif (unit2 is unit1):
        return (converters, unit1)
    else:
        changeable = 1
    if (unit1 is None):
        try:
            converters[changeable] = get_converter(unit2, dimensionless_unscaled)
        except UnitsError:
            converters[(1 - changeable)] = False
            return (converters, unit2)
        else:
            return (converters, dimensionless_unscaled)
    else:
        try:
            converters[changeable] = get_converter(unit2, unit1)
        except UnitsError:
            raise UnitConversionError("Can only apply '{0}' function to quantities with compatible dimensions".format(f.__name__))
        return (converters, unit1)