ddg.abc module

class ddg.abc.Transformable[source]

Bases: object

Makes a class transformable by keeping a stack of transformations.

It is assumed that the transformations are functions. If a matrix is passed to push_transformation, it will be converted to a function.

push_transformation(f)[source]

Add a transformation to the trafo-stack.

Parameters:
fnumpy.ndarray or function
pop_transformation()[source]

Pop transformation from the trafo-stack.

Returns:
function
transform(f)[source]

Wrapper for push_transformation.

property transformation

Composition of all transformations on the stack.

Returns:
function
class ddg.abc.LinearTransformable(trafo_dimension)[source]

Bases: Transformable

Makes a class transformable by keeping a stack of transformations.

It is assumed that the transformations are matrices.

Attributes:
trafo_dimensionint

An empty transformation stack returns np.eye(_trafo_dimension).

push_transformation(f)[source]

Add a transformation to the trafo-stack.

Parameters:
fnumpy.ndarray
property transformation

Product of all matrices on the stack.

Returns:
numpy.ndarray
pop_transformation()

Pop transformation from the trafo-stack.

Returns:
function
transform(f)

Wrapper for push_transformation.

class ddg.abc.NonExact(atol=None, rtol=None)[source]

Bases: object

Adds tolerance attributes to a class.

Parameters:
atolfloat (default=None)

Absolute tolerance

rtolfloat (default=None)

Relative tolerance

atol_default = 1e-07

Absolute tolerance default.

Used for all purposes if atol is None.

rtol_default = 0.0

Relative tolerance default.

Used for all purposes if rtol is None.

property atol
property rtol
classmethod reset_tol_defaults()[source]
classmethod nonexact_function(f)[source]

Decorator to use global tolerance defaults in functions.

If None is given to the wrapped function as the value for atol or rtol, it will be replaced by the global default.

Parameters:
fcallable

Function that takes atol and rtol arguments.

Returns:
callable
ddg.abc.get_tol_defaults()[source]

Get current global tolerance defaults.

Returns:
dict {‘atol’: float, ‘rtol’: float}

Notes

The defaults are stored in the class attributes ddg.abc.NonExact.atol_default and ddg.abc.NonExact.rtol_default. This function is just meant to be elevated to a higher level of the library to make them more accessible.

ddg.abc.set_tol_defaults(atol=None, rtol=None)[source]

Set global tolerance defaults.

Parameters:
atolfloat (default=None)
rtolfloat (default=None)

Notes

The defaults are stored in the class attributes ddg.abc.NonExact.atol_default and ddg.abc.NonExact.rtol_default. This function is just meant to be elevated to a higher level of the library to make them more accessible.

ddg.abc.reset_tol_defaults()[source]

Reset global tolerance defaults to their original values.

Notes

The defaults are stored in the class attributes ddg.abc.NonExact.atol_default and ddg.abc.NonExact.rtol_default. This function is just meant to be elevated to a higher level of the library to make them more accessible.

class ddg.abc.Singleton[source]

Bases: type

Singleton metaclass

mro(/)

Return a type’s method resolution order.