nessai.proposal.flowproposal.truncation
=======================================

.. py:module:: nessai.proposal.flowproposal.truncation

.. autoapi-nested-parse::

   Truncation rules for flow proposals.

   ..
       !! processed by numpydoc !!


Classes
-------

.. autoapisummary::

   nessai.proposal.flowproposal.truncation.BaseTruncationRule
   nessai.proposal.flowproposal.truncation.LatentRadiusTruncation
   nessai.proposal.flowproposal.truncation.MinLogQTruncation
   nessai.proposal.flowproposal.truncation.LikelihoodThresholdTruncation
   nessai.proposal.flowproposal.truncation.TruncationScheme


Functions
---------

.. autoapisummary::

   nessai.proposal.flowproposal.truncation.get_deprecated_latent_radius_arguments
   nessai.proposal.flowproposal.truncation.get_deprecated_latent_radius_kwargs
   nessai.proposal.flowproposal.truncation.normalise_truncation_methods
   nessai.proposal.flowproposal.truncation.should_enable_latent_radius
   nessai.proposal.flowproposal.truncation.build_truncation_methods
   nessai.proposal.flowproposal.truncation.apply_default_truncation_config
   nessai.proposal.flowproposal.truncation.normalise_truncation_kwargs
   nessai.proposal.flowproposal.truncation.get_truncation_rule_class


Module Contents
---------------

.. py:function:: get_deprecated_latent_radius_arguments(**kwargs) -> list[str]

   
   Return deprecated latent-radius arguments that were explicitly set.
















   ..
       !! processed by numpydoc !!

.. py:function:: get_deprecated_latent_radius_kwargs(**kwargs) -> dict

   
   Build sparse latent-radius kwargs from deprecated proposal arguments.
















   ..
       !! processed by numpydoc !!

.. py:function:: normalise_truncation_methods(truncation_method=None, truncation_methods=None) -> list[str]

   
   Normalise truncation-method input into an ordered unique list.
















   ..
       !! processed by numpydoc !!

.. py:function:: should_enable_latent_radius(latent_radius_kwargs=None) -> bool

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
















   ..
       !! processed by numpydoc !!

.. py:function:: 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.
















   ..
       !! processed by numpydoc !!

.. py:function:: apply_default_truncation_config(methods, truncation_kwargs=None, *, default_latent_radius: bool = False)

   
   Apply canonical default truncation configuration.
















   ..
       !! processed by numpydoc !!

.. py:function:: normalise_truncation_kwargs(truncation_method=None, truncation_methods=None, truncation_kwargs=None)

   
   Normalise truncation kwargs into the canonical method-keyed form.
















   ..
       !! processed by numpydoc !!

.. py:class:: BaseTruncationRule

   
   Base class for truncation rules.
















   ..
       !! processed by numpydoc !!

   .. py:property:: requires_log_likelihood
      :type: bool


      
      Indicate if the rule needs log-likelihood values.
















      ..
          !! processed by numpydoc !!


   .. py:method:: configure(proposal) -> None

      
      Apply any proposal-level configuration needed by the rule.
















      ..
          !! processed by numpydoc !!


   .. py:method:: prepare(proposal, worst_point, radius=None)

      
      Prepare per-population data for the rule.
















      ..
          !! processed by numpydoc !!


   .. py:method:: apply_latent(proposal, z)

      
      Apply truncation in latent space before the inverse pass.
















      ..
          !! processed by numpydoc !!


   .. py:method:: apply_after_backward(proposal, x, log_q, z)

      
      Apply truncation after the inverse pass and rescaling.
















      ..
          !! processed by numpydoc !!


   .. py:method:: apply_after_likelihood(proposal, x, log_q, z)

      
      Apply truncation after likelihood evaluation.
















      ..
          !! processed by numpydoc !!


   .. py:method:: reset() -> None

      
      Reset transient state.
















      ..
          !! processed by numpydoc !!


.. py:class:: 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: :py:obj:`BaseTruncationRule`


   
   Filter latent samples using a radial threshold.
















   ..
       !! processed by numpydoc !!

   .. py:method:: to_kwargs() -> dict

      
      Return keyword arguments that reconstruct the rule.
















      ..
          !! processed by numpydoc !!


   .. py:method:: configure(proposal) -> None

      
      Apply any proposal-level configuration needed by the rule.
















      ..
          !! processed by numpydoc !!


   .. py:method:: prepare(proposal, worst_point, radius=None)

      
      Prepare per-population data for the rule.
















      ..
          !! processed by numpydoc !!


   .. py:method:: apply_latent(proposal, z)

      
      Apply truncation in latent space before the inverse pass.
















      ..
          !! processed by numpydoc !!


.. py:class:: MinLogQTruncation

   Bases: :py:obj:`BaseTruncationRule`


   
   Truncate samples using the minimum live-point log q.
















   ..
       !! processed by numpydoc !!

   .. py:method:: prepare(proposal, worst_point, radius=None)

      
      Prepare per-population data for the rule.
















      ..
          !! processed by numpydoc !!


   .. py:method:: apply_after_backward(proposal, x, log_q, z)

      
      Apply truncation after the inverse pass and rescaling.
















      ..
          !! processed by numpydoc !!


.. py:class:: LikelihoodThresholdTruncation

   Bases: :py:obj:`BaseTruncationRule`


   
   Truncate samples using the current likelihood threshold.
















   ..
       !! processed by numpydoc !!

   .. py:property:: requires_log_likelihood
      :type: bool


      
      Indicate if the rule needs log-likelihood values.
















      ..
          !! processed by numpydoc !!


   .. py:method:: prepare(proposal, worst_point, radius=None)

      
      Prepare per-population data for the rule.
















      ..
          !! processed by numpydoc !!


   .. py:method:: apply_after_likelihood(proposal, x, log_q, z)

      
      Apply truncation after likelihood evaluation.
















      ..
          !! processed by numpydoc !!


.. py:function:: get_truncation_rule_class(name: str)

   
   Get the truncation rule class for a configured method name.
















   ..
       !! processed by numpydoc !!

.. py:class:: TruncationScheme(rules: list[BaseTruncationRule] | None = None)

   
   Apply an ordered set of truncation rules.
















   ..
       !! processed by numpydoc !!

