computation

Computation Primitives and Conversions

Core building blocks for computing distribution characteristics and conversions between them (e.g., PDF to CDF, CDF to PPF).

This module provides: - FittedComputationMethod: fitted conversion method ready for use - FitterMethod: cacheable computation that performs expensive precomputation - EvaluatorMethod: lightweight direct computation called on every query - AnalyticalComputation: analytical computation provided directly by a distribution - Computation: protocol for computations that evaluate a single characteristic

class pysatl_core.distributions.computations.computation.AnalyticalComputation(target, func)[source]

Bases: Generic

Analytical computation provided directly by a distribution.

Parameters:
  • target (str) – Characteristic name (e.g., “pdf”, “cdf”).

  • func (ComputationFunc[In, Out]) – Analytical function that computes the characteristic.

__init__(target, func)
Parameters:
  • target (GenericCharacteristicName)

  • func (ComputationFunc[Any, Any])

Return type:

None

target: TypeAliasType
func: GenericAlias[TypeVar(In), TypeVar(Out)]
__call__(*args, **options)[source]

Evaluate the analytical function.

Return type:

typing.Any

Parameters:
class pysatl_core.distributions.computations.computation.Computation(*args, **kwargs)[source]

Bases: Protocol, Generic

Protocol for computations that evaluate a single characteristic.

target

Name of the characteristic this computation produces.

Type:

str

property target: GenericCharacteristicName
__init__(*args, **kwargs)
class pysatl_core.distributions.computations.computation.EvaluatorMethod(target, sources, evaluator)[source]

Bases: object

Lightweight direct computation method called on every query.

An evaluator does not perform expensive precomputation and returns the computed value directly rather than a FittedComputationMethod.

Parameters:
  • target (str) – Destination characteristic name.

  • sources (Sequence[str]) – Source characteristic names (typically length 1 for unary conversions).

  • evaluator (EvaluatorFunc) – Direct evaluator callable.

target: TypeAliasType
sources: Sequence[TypeAliasType]
evaluator: TypeAliasType
property cacheable: bool

Evaluators are not cacheable.

evaluate(distribution, *args, **options)[source]

Evaluate the computation directly.

Parameters:
  • distribution (Distribution) – Distribution to evaluate for.

  • *args (Any) – Optional positional data argument.

  • **options (Any) – Additional options.

Returns:

Computed result.

Return type:

NumericArray

prepare(distribution, **options)[source]

Create a lightweight fitted wrapper that binds the distribution.

This allows evaluator-based methods to be used in the same way as fitter-based methods when needed.

Return type:

FittedComputationMethod[TypeAliasType, TypeAliasType]

Parameters:
__init__(target, sources, evaluator)
Parameters:
  • target (GenericCharacteristicName)

  • sources (Sequence[GenericCharacteristicName])

  • evaluator (EvaluatorFunc)

Return type:

None

class pysatl_core.distributions.computations.computation.FittedComputationMethod(target, sources, func)[source]

Bases: Generic

Fitted conversion method ready for use.

Parameters:
  • target (str) – Destination characteristic name.

  • sources (Sequence[str]) – Source characteristic names (typically length 1 for unary conversions).

  • func (ComputationFunc[In, Out]) – Callable implementing the fitted conversion.

target: TypeAliasType
sources: Sequence[TypeAliasType]
func: GenericAlias[TypeVar(In), TypeVar(Out)]
__call__(*args, **options)[source]

Evaluate the fitted conversion.

Return type:

typing.Any

Parameters:
__init__(target, sources, func)
Parameters:
  • target (GenericCharacteristicName)

  • sources (Sequence[GenericCharacteristicName])

  • func (ComputationFunc[Any, Any])

Return type:

None

class pysatl_core.distributions.computations.computation.FitterMethod(target, sources, fitter)[source]

Bases: object

Cacheable computation method that performs expensive precomputation.

A fitter is called once per distribution to produce a FittedComputationMethod that can be cached and reused for subsequent evaluations.

Parameters:
  • target (str) – Destination characteristic name.

  • sources (Sequence[str]) – Source characteristic names (typically length 1 for unary conversions).

  • fitter (FitterFunc) – Function that fits the computation method to a distribution.

target: TypeAliasType
sources: Sequence[TypeAliasType]
fitter: TypeAliasType
property cacheable: bool

Whether it makes sense to cache the prepared method at strategy level.

fit(distribution, **options)[source]

Fit the computation method to a specific distribution.

Parameters:
  • distribution (Distribution) – Distribution to fit the computation method to.

  • **options (Any) – Additional options passed to the fitter.

Returns:

Fitted method ready for evaluation.

Return type:

FittedComputationMethod

prepare(distribution, **options)[source]

Alias for fit().

Return type:

FittedComputationMethod[TypeAliasType, TypeAliasType]

Parameters:
__init__(target, sources, fitter)
Parameters:
  • target (GenericCharacteristicName)

  • sources (Sequence[GenericCharacteristicName])

  • fitter (FitterFunc)

Return type:

None