intermol.decorators module¶
- exception intermol.decorators.UnitsException(value)[source]¶
Bases: exceptions.Exception
Exception denoting that an argument has the incorrect units.
- exception intermol.decorators.ValueException(value)[source]¶
Bases: exceptions.Exception
Exception denoting that an argument has the incorrect value.
- intermol.decorators.accepts(*types)[source]¶
Decorator for class methods that should accept only specified types.
EXAMPLE
@accepts(float, int) def function(a, b):
return b*a
- intermol.decorators.accepts_compatible_units(*units, **unitdict)[source]¶
Decorator for class methods that should accept only arguments compatible with specified units.
Each argument of the function will be matched with an argument of @acceptunits. Those arguments of the function that correspond @acceptunits which are not None will be checked to ensure they are compatible with the specified units.
EXAMPLE
@acceptsunits(units.meter, None, units.kilocalories_per_mole) def function(a, b, c): pass function(1.0 * units.angstrom, 3, 1.0 * units.kilojoules_per_mole)