cobald.utility package

exception cobald.utility.InvariantError[source]

Bases: Exception

An invariant is violated

cobald.utility.enforce(condition: bool, exception: BaseException = InvariantError())[source]

Enforce that condition is set by raising exception otherwise

This is a replacement for assert statements as part of validation. It cannot be disabled with -O and may raise arbitrary exceptions.

def sqrt(value):
    condition(value > 0, ValueError('value must be greater than zero')
    return math.sqrt(value)
cobald.utility.pairwise(iterable)[source]

Iterator yielding consecutive pairs from iterable

Submodules