pisces.models.core.hooks#

Pisces model hook framework.

This module defines the infrastructure for attaching modular, reusable components—called hooks—to Pisces models. Hooks encapsulate specialized behavior such as sampling, diagnostics, or derived computation, and can be selectively enabled or disabled on a per-model basis.

Usage#

To use a hook, mix it into a model class and optionally configure it via class-level attributes. Hooks are automatically detected and can be accessed via the tools in _HookTools.

Examples

class MyModel(BaseModel, MyCustomHook):
    __MyCustomHook_HOOK_ENABLED__ = True
    _MyCustomHook_option = 42

model = MyModel()
model.get_active_hooks()  # -> ['my_custom_hook']

Design Notes#

Hooks are designed to be:

  • Non-intrusive: They extend model behavior without modifying the base logic.

  • Declarative: They rely on class-level flags and naming conventions for control.

  • Discoverable: They support standardized metadata for reflection and documentation.

For more details on creating or customizing hooks, see the docstring for BaseHook.

Classes

BaseHook()

Base class for all Pisces model hooks.

ParticleGenerationHook()

Abstract hook for converting models into particle datasets.

SphericalParticleGenerationHook()

Template hook for sampling particles from spherically symmetric models.