Skip to content

Observation scoring

observation_scoring(False) omits declared observation likelihoods and compiler-generated marginal likelihood factors during execution. Latent priors, their support constraints, and authored score potentials retain their scores. The policy avoids evaluating the omitted density, including an inactive response law whose parameters would be invalid for the recorded outcome.

The policy changes scoring only. Recorded values, raw pointwise likelihood accessors, and the response-generating distribution retain their usual meaning. Handlers compose by scope, with the innermost policy taking precedence, and leaving a scope restores the enclosing policy even after an exception.

observation_scoring

Select likelihood scoring without changing priors, observations, or sampling.

ObservationScoringHandler

ObservationScoringHandler(enabled: bool = True)

Bases: EffectHandler

Choose whether declared observations and likelihood factors contribute.

Latent draws and explicit score potentials retain their ordinary scores. Recorded values and raw likelihoods are unchanged; disabling likelihood scoring avoids evaluating that likelihood at all.

PARAMETER DESCRIPTION
enabled

Include likelihood scores when true; omit them when false.

TYPE: bool DEFAULT: True

Source code in src/quivers/effects/observation_scoring.py
def __init__(self, enabled: bool = True) -> None:
    if type(enabled) is not bool:
        raise TypeError("observation scoring requires a Boolean policy")
    self.enabled = enabled

install

install(run: RunContext) -> tuple[Installation, ...]

Set this execution's policy, with innermost scopes taking precedence.

PARAMETER DESCRIPTION
run

Isolated per-run state, shared by its native host steps.

TYPE: RunContext

RETURNS DESCRIPTION
tuple[Installation, ...]

No effect is replaced; existing host boundaries read the policy.

Source code in src/quivers/effects/observation_scoring.py
def install(self, run: RunContext) -> tuple[Installation, ...]:
    """Set this execution's policy, with innermost scopes taking precedence.

    Parameters
    ----------
    run : RunContext
        Isolated per-run state, shared by its native host steps.

    Returns
    -------
    tuple[Installation, ...]
        No effect is replaced; existing host boundaries read the policy.
    """
    run.annotations.setdefault(_POLICY, {})["enabled"] = self.enabled
    return ()

observation_scoring

observation_scoring(enabled: bool = True) -> ObservationScoringHandler

Create a scoped likelihood policy shared by fitting interfaces.

PARAMETER DESCRIPTION
enabled

Whether observations and classified likelihood factors are scored.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
ObservationScoringHandler

A reusable context manager; latent priors and score potentials remain.

Source code in src/quivers/effects/observation_scoring.py
def observation_scoring(enabled: bool = True) -> ObservationScoringHandler:
    """Create a scoped likelihood policy shared by fitting interfaces.

    Parameters
    ----------
    enabled : bool
        Whether observations and classified likelihood factors are scored.

    Returns
    -------
    ObservationScoringHandler
        A reusable context manager; latent priors and score potentials remain.
    """
    return ObservationScoringHandler(enabled)