def unit(val, **kw):
    _unit = kw.get("unit", DEFAULT_UNIT)
    if _unit != None:
        _unit = units.parse_expression(_unit)
    if type(val) != units.Quantity:
        if type(val) in (int, float):
            assert _unit, "value %r of type '%r' requires a unit definition" % (val, type(val))
            val = val * _unit
        elif (str, unicode) in type(val):
            val = units.parse_expression(val)
        else:
            raise TypeError, "I don't know how to convert type '%s' to a unit" % str(type(val))
    assert type(val) == units.Quantity, "%r != %r" % (type(val), units.Quantity)
    if _unit:
        val = val.to(_unit)
    return val
dataset/ETHPy150Open vishnubob/silhouette/src/utils.py/unit/swapped operands of `in`