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
ConverterBasesubclass acts as a stateless callable that accepts aStatisticalModel(or any other representation) and returns a newBackendBaseinstance. 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
ConverterBasesubclasses 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
__init__()