gwkokab.models.wrappers¶

Registry mapping parameter names to the models that produce them.

ModelRegistry is a small decorator-based lookup: a model registers itself against the parameter name (or tuple of names) it is a distribution over, and calling the registry with that name builds the model. This lets a family’s --add-* CLI flags select models by parameter name without a hard-coded dispatch table.

Classes¶

ModelRegistry

Decorator class to register models and their parameters.

Module Contents¶

class gwkokab.models.wrappers.ModelRegistry¶

Bases: object

Decorator class to register models and their parameters.

A model is registered against the parameter name, or tuple of names, it is a distribution over; calling the registry with that key constructs the model.

Examples

registry = ModelRegistry()

@registry.register("redshift")
def redshift_model(parameter): ...


model = registry("redshift")
register(parameter, model=None)¶

Register a model with the parameter(s) it yields.

Usable directly or as a decorator: omitting model returns a decorator that registers the function it is applied to.

Parameters:
  • parameter (str | tuple[str, ...]) – The parameter name, or tuple of names, the model is a distribution over. A bare string is promoted to a one-element tuple.

  • model (Callable, optional) – The model factory. Defaults to None, which returns a decorator.

Returns:

The registered model, or a decorator when model is None.

Return type:

Callable

Raises:

ValueError – If parameter is neither a string nor a tuple of strings.

property registry: dict¶

Hashmap of registered models and their parameters.

Returns:

Maps each registered tuple of parameter names to its model factory.

Return type:

dict