mutwo.utilities.decorators

Generic decorators that are used within mutwo.

Functions:

add_return_option(function)

This decorator adds a return option for object mutating methods.

add_return_option(function)[source]

This decorator adds a return option for object mutating methods.

The ‘add_return_option’ decorator adds the ‘mutate’ keyword argument to the decorated method. If ‘mutate’ is set to False, the decorator deep copies the respective object, then applies the called method on the new copied object and finally returns the copied object. This can be useful for methods that by default mutate its object. When adding this method, it is up to the user whether the original object shall be changed (for mutate=True) or if a copied version of the object with the respective mutation shall be returned (for mutate=False).

Parameters

function (mutwo.utilities.decorators.F) –

Return type

mutwo.utilities.decorators.F