Beispiel #1
0
 def __mul__(cls, other):
     if isinstance(other, Number):
         return ValueWithUnits(other, cls)
     elif isinstance(other, Unit):
         return CompositeUnit({cls: 1, other: 1})
     else:
         return NotImplemented
Beispiel #2
0
 def __pow__(cls, power):
     if isinstance(power, Real):
         return CompositeUnit({cls: power})
     else: # pragma: no cover
         return NotImplemented
Beispiel #3
0
 def __rdiv__(cls, other):
     if isinstance(other, Number):
         return ValueWithUnits(other, CompositeUnit({cls: -1}))
     else: # pragma: no cover
         return NotImplemented
Beispiel #4
0
 def __div__(cls, other):
     if isinstance(other, Unit):
         return CompositeUnit({cls: 1, other:-1})
     else:
         return NotImplemented