spey.base.backend_base.ConverterBase

spey.base.backend_base.ConverterBase#

class spey.base.backend_base.ConverterBase[source]#

Abstract base class for objects that convert one statistical model into another.

A ConverterBase subclass acts as a stateless callable that accepts a StatisticalModel (or any other representation) and returns a new BackendBase instance. This is useful for translating between different likelihood prescriptions without exposing construction details to the user.

Subclasses must expose the same class-level metadata as BackendBase (name, version, author, spey_requires) so that the plugin registry can identify them, and must override __call__() to perform the actual conversion.

Note

ConverterBase subclasses are not expected to accept arguments in __init__. All conversion logic should live in __call__().

Example:

import spey
from spey.base.backend_base import BackendBase, ConverterBase

class MyStatConverter(ConverterBase):
    name          = "example.converter"
    version       = "0.0.1"
    author        = "Tom Bombadil"
    spey_requires = ">=0.1.0"

    def __call__(self, stat_model: spey.StatisticalModel) -> BackendBase:
        # Extract information from the input model and build a new backend
        signal     = stat_model.backend._signal
        background = stat_model.backend._background
        data       = stat_model.backend._data
        return UncorrelatedBackground(signal, background, data)
__init__()#

Methods