bind_lite_func

plasmapy.utils.decorators.lite_func.bind_lite_func(lite_func, attrs: dict[str, Callable] | None = None)[source]

Decorator to bind a lightweight “lite” version of a formulary function to the full formulary function, as well as any supporting attributes.

Parameters:
  • lite_func (Callable) – The lightweight function to be bound as the lite attribute to the function being decorated.

  • attrs (Dict[str, Callable]) – A dictionary where the key is a string defining the bound name and the associated value is the functionality to be bound.

Examples

def foo_lite(x):
    return x

def bar():
    print("Supporting function.")


@bind_lite_func(
    foo_lite,
    attrs=[
        ("bar", bar),
    ],
)
def foo(x):
    if not isinstance(x, float):
        raise TypeError("Argument x can only be a float.")
    return x
>>> foo(5)  
5
>>> foo.lite(5)  
5
>>> foo.bar()  
Supporting function.

Notes

In addition to binding the functionality defined by the inputs, a __bound_lite_func__ dunder is bound. This dunder is a dictionary where a key is a string representing the bound name of the bound functionality and the associated value is a string representing the fully qualified path of the original bound functionality.