Decorator

Useful utility decorators.

diofant.utilities.decorator.conserve_mpmath_dps(func)[source]

After the function finishes, resets the value of mpmath.mp.dps to the value it had before the function was run.

diofant.utilities.decorator.doctest_depends_on(exe=None, modules=None, disable_viewers=None)[source]

Adds metadata about the dependencies which need to be met for doctesting the docstrings of the decorated objects.

class diofant.utilities.decorator.no_attrs_in_subclass(cls, f)[source]

Don’t ‘inherit’ certain attributes from a base class

>>> class A:
...     x = 'test'
>>> A.x = no_attrs_in_subclass(A, A.x)
>>> class B(A):
...     pass
>>> hasattr(A, 'x')
True
>>> hasattr(B, 'x')
False