Hooks

Inheritance diagram of hermespy.core.hooks.Hook, hermespy.core.hooks.Hookable

Hooks and hookables represent callback functions and their respective call sites within HermesPy’s processing pipeline. They are deployed to report the results of different signal processing stages to trigger additional caching and post-processing steps.

class Hook(hookable, callback)[source]

Bases: Generic[_RT]

Hook for a callback to be called after a specific DSP layer was called.

Parameters:
  • hookable (Hookable[_RT]) – DSP layer to be hooked into by the represented callback.

  • callback (Callable[[_RT], None]) – Function to called after processing the DSP layer. The DSP layer’s output is passed as the only argument.

remove()[source]

Remove the callback from the DSP layer.

Return type:

None

class Hookable[source]

Bases: Generic[_RT]

Base class of DSP layers that can be hooked into by callbacks.

add_callback(callback)[source]

Add a callback to be called after processing the DSP layer.

Instantiates a new Hook object representing the provided callback function. Note that each Hook instance should notify the Hookable by calling its Hook.remove() method once the represented callback is no longer required.

Parameters:

callback (Callable[[_RT], None]) – Function to called after processing the DSP layer. The DSP layer’s output is passed as the only argument.

Return type:

Hook[TypeVar(_RT)]

Returns: The added callback hook.

add_hook(hook)[source]

Add a callback to be called after processing the DSP layer.

Parameters:

hook (Hook[_RT]) – Hook to be added.

Return type:

None

notify(output)[source]

Notify all registered callbacks of the DSP layer.

Parameters:

output (_RT) – Output of the DSP layer.

Return type:

None

remove_hook(hook)[source]

Remove a callback hook from this DSP layer.

Parameters:

hook (Hook[_RT]) – Hook to be removed.

Return type:

None

class _RT

Type of operation result.

alias of TypeVar(‘_RT’)