nessai.proposal.flowproposal.truncation#

Truncation rules for flow proposals.

Classes#

BaseTruncationRule

Base class for truncation rules.

LatentRadiusTruncation

Filter latent samples using a radial threshold.

MinLogQTruncation

Truncate samples using the minimum live-point log q.

LikelihoodThresholdTruncation

Truncate samples using the current likelihood threshold.

TruncationScheme

Apply an ordered set of truncation rules.

Functions#

get_deprecated_latent_radius_arguments(→ list[str])

Return deprecated latent-radius arguments that were explicitly set.

get_deprecated_latent_radius_kwargs(→ dict)

Build sparse latent-radius kwargs from deprecated proposal arguments.

normalise_truncation_methods(→ list[str])

Normalise truncation-method input into an ordered unique list.

should_enable_latent_radius(→ bool)

Check if latent-radius truncation should be enabled from kwargs.

build_truncation_methods(→ list[str])

Build the effective truncation-method list from legacy and new inputs.

apply_default_truncation_config(methods[, ...])

Apply canonical default truncation configuration.

normalise_truncation_kwargs([truncation_method, ...])

Normalise truncation kwargs into the canonical method-keyed form.

get_truncation_rule_class(name)

Get the truncation rule class for a configured method name.

Module Contents#

nessai.proposal.flowproposal.truncation.get_deprecated_latent_radius_arguments(**kwargs) list[str]#

Return deprecated latent-radius arguments that were explicitly set.

nessai.proposal.flowproposal.truncation.get_deprecated_latent_radius_kwargs(**kwargs) dict#

Build sparse latent-radius kwargs from deprecated proposal arguments.

nessai.proposal.flowproposal.truncation.normalise_truncation_methods(truncation_method=None, truncation_methods=None) list[str]#

Normalise truncation-method input into an ordered unique list.

nessai.proposal.flowproposal.truncation.should_enable_latent_radius(latent_radius_kwargs=None) bool#

Check if latent-radius truncation should be enabled from kwargs.

nessai.proposal.flowproposal.truncation.build_truncation_methods(truncation_method=None, truncation_methods=None, truncate_log_q=False, enforce_likelihood_threshold=False, latent_radius_kwargs=None, default_latent_radius: bool = False) list[str]#

Build the effective truncation-method list from legacy and new inputs.

nessai.proposal.flowproposal.truncation.apply_default_truncation_config(methods, truncation_kwargs=None, *, default_latent_radius: bool = False)#

Apply canonical default truncation configuration.

nessai.proposal.flowproposal.truncation.normalise_truncation_kwargs(truncation_method=None, truncation_methods=None, truncation_kwargs=None)#

Normalise truncation kwargs into the canonical method-keyed form.

class nessai.proposal.flowproposal.truncation.BaseTruncationRule#

Base class for truncation rules.

property requires_log_likelihood: bool#

Indicate if the rule needs log-likelihood values.

configure(proposal) None#

Apply any proposal-level configuration needed by the rule.

prepare(proposal, worst_point, radius=None)#

Prepare per-population data for the rule.

apply_latent(proposal, z)#

Apply truncation in latent space before the inverse pass.

apply_after_backward(proposal, x, log_q, z)#

Apply truncation after the inverse pass and rescaling.

apply_after_likelihood(proposal, x, log_q, z)#

Apply truncation after likelihood evaluation.

reset() None#

Reset transient state.

class nessai.proposal.flowproposal.truncation.LatentRadiusTruncation(radius_mode: str | None = None, fixed_radius: float | bool = False, min_radius: float | bool = False, max_radius: float | bool = 50.0, compute_radius_with_all: bool = False, constant_volume_mode: bool = False, volume_fraction: float = 0.95, fuzz: float = 1.0, expansion_fraction: float | None = 4.0)#

Bases: BaseTruncationRule

Filter latent samples using a radial threshold.

to_kwargs() dict#

Return keyword arguments that reconstruct the rule.

configure(proposal) None#

Apply any proposal-level configuration needed by the rule.

prepare(proposal, worst_point, radius=None)#

Prepare per-population data for the rule.

apply_latent(proposal, z)#

Apply truncation in latent space before the inverse pass.

class nessai.proposal.flowproposal.truncation.MinLogQTruncation#

Bases: BaseTruncationRule

Truncate samples using the minimum live-point log q.

prepare(proposal, worst_point, radius=None)#

Prepare per-population data for the rule.

apply_after_backward(proposal, x, log_q, z)#

Apply truncation after the inverse pass and rescaling.

class nessai.proposal.flowproposal.truncation.LikelihoodThresholdTruncation#

Bases: BaseTruncationRule

Truncate samples using the current likelihood threshold.

property requires_log_likelihood: bool#

Indicate if the rule needs log-likelihood values.

prepare(proposal, worst_point, radius=None)#

Prepare per-population data for the rule.

apply_after_likelihood(proposal, x, log_q, z)#

Apply truncation after likelihood evaluation.

nessai.proposal.flowproposal.truncation.get_truncation_rule_class(name: str)#

Get the truncation rule class for a configured method name.

class nessai.proposal.flowproposal.truncation.TruncationScheme(rules: list[BaseTruncationRule] | None = None)#

Apply an ordered set of truncation rules.