sequince.steps.mutation.base#

Attributes#

Classes#

MutationStep

Base class for mutations that optionally operate in transformed space.

Functions#

call_log_prob(fn, position, context)

as_scalar_log_prob(value)

as_vector_log_prob(value, length)

Module Contents#

sequince.steps.mutation.base.LogProbFn#
sequince.steps.mutation.base.PARTICLE_TRANSFORM_KEY = 'particle_transform'#
sequince.steps.mutation.base.TransformRefit#
sequince.steps.mutation.base.call_log_prob(fn, position, context)[source]#
Parameters:
Return type:

Any

sequince.steps.mutation.base.as_scalar_log_prob(value)[source]#
Parameters:

value (Any)

Return type:

float

sequince.steps.mutation.base.as_vector_log_prob(value, length)[source]#
Parameters:
  • value (Any)

  • length (int)

Return type:

numpy.ndarray

class sequince.steps.mutation.base.MutationStep(log_prob_fn, *, transform=None, transform_refit='always', store_chains=False, metrics=())[source]#

Bases: sequince.steps.base.SMCStep

Base class for mutations that optionally operate in transformed space.

transform_refit controls whether a cloned transform is fitted for every mutation call, once per outer StepContext, or only once for the lifetime of this mutation step. A callable can instead request fits based on the particles and context. It is evaluated once per mutation application, including the initial fit, and may consume or reset a trigger stored in the context.

Parameters:
metrics#
property n_steps: int#

Default transition count for one standalone application.

Return type:

int

abstractmethod apply_with_mutation_state(state, context, rng, *, n_steps, mutation_state=None)[source]#

Run transitions within a block without finalizing metrics.

Pass mutation_state=None to initialize a new block; otherwise pass the state returned by the preceding call. The state holds individual metric states and cumulative acceptance bookkeeping. It must belong to the same metric configuration and mutation coordinate space.

Returns (state, context, output, mutation_state). The output’s metrics remain unset, including on the first and zero-step calls. Concrete mutations prepare existing metrics on entry, update state for each transition, and return it explicitly without calling metric.result(). Runtime state must never be stored on the mutation object.

Use apply or apply_with_n_steps for a complete standalone block. RepeatedMutationStep uses this method to continue across rounds and finalizes metrics once after the complete block.

Parameters:
Return type:

tuple[sequince.state.ParticleState, sequince.steps.context.StepContext, Any, sequince.steps.mutation.metrics.MutationStepState | None]

apply_with_n_steps(state, context, rng, *, n_steps)[source]#

Run a complete fixed-length block and finalize its configured metrics.

property store_chains: bool#

Whether full mutation chains are included in step outputs.

Return type:

bool

state_dict()[source]#

Return the fitted transform and the context identifying its fit.

Return type:

dict[str, Any]

load_state_dict(state)[source]#

Restore the transform cache; legacy empty state clears the cache.

Parameters:

state (collections.abc.Mapping[str, Any])

Return type:

None

initialize_functional_state_and_context(state, context)[source]#

Initialize cached target data and functional transform state.

Parameters:
Return type:

tuple[sequince.state.ParticleState, sequince.steps.context.StepContext]