spekk.transformations.base.TransformedFunction#

class spekk.transformations.base.TransformedFunction(wrapped_fn: Union[<built-in function callable>, ForwardRef('TransformedFunction')], transformation: 'Transformation')[source]#

Bases: Buildable

__init__(wrapped_fn: callable | TransformedFunction, transformation: Transformation) None#

Methods

__init__(wrapped_fn, transformation)

build(input_spec)

Return a copy of this object with information about what happens to the spec when the function is called.

traverse(*[, depth_first])

Recursively yield the potentially nested TransformedFunction.

Attributes

input_spec

The spec for the input kwargs for the function.

output_spec

The spec of the final returned value from the transformed function.

passed_spec

The spec for the input kwargs that are passed down into the wrapped function after the transformation has been applied.

returned_spec

The spec of the returned value from the wrapped function.

wrapped_fn

The original function that was wrapped by the transformation.

transformation

The Transformation that was applied to the wrapped function.

build(input_spec: Spec) TransformedFunction[source]#

Return a copy of this object with information about what happens to the spec when the function is called.

input_spec: Spec | None = None#

The spec for the input kwargs for the function.

output_spec: Spec | None = None#

The spec of the final returned value from the transformed function.

passed_spec: Spec | None = None#

The spec for the input kwargs that are passed down into the wrapped function after the transformation has been applied.

returned_spec: Spec | None = None#

The spec of the returned value from the wrapped function.

transformation: Transformation#

The Transformation that was applied to the wrapped function.

traverse(*, depth_first: bool = False)[source]#

Recursively yield the potentially nested TransformedFunction.

>>> from spekk.transformations import ForAll, compose, TransformedFunction
>>> tf = compose(abs, ForAll("x"), ForAll("y"))
>>> for t in tf.traverse():
...     if isinstance(t, TransformedFunction):
...         t = t.transformation  # Print transformation, not TransformedFunction
...     print(repr(t))
ForAll("y")
ForAll("x")
<built-in function abs>
wrapped_fn: callable | TransformedFunction#

The original function that was wrapped by the transformation.