quantammsim.pools.creator.create_hooked_pool_instance
- create_hooked_pool_instance(base_pool_class, *hooks)[source]
Create a pool instance with hook classes mixed in via Python MRO.
Constructs a dynamic
_HookedPoolclass whose MRO places the hook classes before the base pool class, then instantiates it. Hooks are applied right-to-left so that the first hook listed has the highest priority in method dispatch (i.e. its methods shadow those of later hooks and the base pool).The resulting mixed class is registered as a JAX pytree, which is required for the instance to be passed through
jit-compiled functions.- Parameters:
base_pool_class (Type[P]) – The pool class to use as the base, e.g.
MomentumPool,MeanReversionChannelPool.*hooks (Type) – One or more hook classes to mix in, e.g.
BoundedWeightsHook,EnsembleAveragingHook. The first hook listed takes highest priority in the MRO.
- Returns:
An instance of the dynamically created
_HookedPoolclass, with all hook and base-pool methods available via standard Python method resolution.- Return type:
P
Examples
>>> pool = create_hooked_pool_instance( ... MomentumPool, EnsembleAveragingHook, BoundedWeightsHook ... )