3.1.4. qctoolkit.utils package

3.1.4.1. Submodules

3.1.4.2. qctoolkit.utils.type_check module

RELATED THIRD PARTY IMPORTS

exception qctoolkit.utils.type_check.MismatchingTypesException(message) → None[source]

Bases: Exception

Exception raised when a type error occurs in “type_check”

Has the behaviour of an default Exception due inheritance of the self.

qctoolkit.utils.type_check.typecheck(same_length: bool = False, raise_on_error: bool = False, log: bool = True)[source]

Decorator for functions, invokes typechecking on their annotation

This function invokes the typechecking on functions which uses the annotations of python3. This type check will happen in runtime.

For the “same_length” argument, please reference to “__equal_types”.

There are two ways, this function can react on type errors: 1. “raise_on_error” will raise an “MismatchingTypeException” defined below. 2. “log” will create a logging message on the warning level.

Usage: “@typecheck: ‘def f(x):”

3.1.4.3. Module contents