pymixef.compare module

Cross-platform parameter and objective comparison.

class pymixef.compare.ComparisonResult(table, compatibility, objective_difference, conventions)[source]

Bases: object

Aligned comparison plus its convention-compatibility report.

Parameters:
table: DiagnosticTable
compatibility: CompatibilityReport
objective_difference: float | None
conventions: Mapping[str, Any]
to_dict()[source]
Return type:

dict[str, Any]

assert_within(tolerances)[source]
Parameters:

tolerances (Mapping[str, float])

Return type:

None

write_report(path)[source]
Parameters:

path (str | Path)

Return type:

Path

class pymixef.compare.ApproximationSensitivityResult(table, fits, failures, baseline, settings, materiality)[source]

Bases: object

Cross-setting refit comparisons with explicit failure accounting.

Parameters:
  • table (DiagnosticTable)

  • fits (Mapping[str, FitResult])

  • failures (tuple[Mapping[str, Any], ...])

  • baseline (str)

  • settings (Mapping[str, Mapping[str, Any]])

  • materiality (Mapping[str, float])

table: DiagnosticTable
fits: Mapping[str, FitResult]
failures: tuple[Mapping[str, Any], ...]
baseline: str
settings: Mapping[str, Mapping[str, Any]]
materiality: Mapping[str, float]
property successful_scenarios: int

Number of settings whose fit completed successfully.

property failed_scenarios: int

Number of settings whose fit failed or returned unusable output.

to_dict()[source]

Return the comparison and scenario metadata without duplicating fits.

Return type:

dict[str, Any]

pymixef.compare.approximation_sensitivity(fit_function, scenarios, *, materiality, baseline=None)[source]

Refit named approximation settings and compare aligned outputs.

fit_function receives an independent deep copy of one settings mapping per scenario. The baseline must succeed; other failures are retained with scenario, exception type, and message. Successful fits must expose the same parameter names and an aligned parameter covariance matrix. The tidy result reports parameter, standard-error, and objective changes relative to the baseline.

materiality must define nonnegative thresholds named parameter_relative, standard_error_relative, and objective_absolute. Per-row flags preserve the caller’s scientific decision rule instead of embedding an undocumented universal threshold.

This callback-based contract supports sensitivity analyses such as Laplace optimizer tolerances, MMRM covariance/degree-of-freedom choices, or ODE solver tolerances without embedding engine-specific assumptions.

Parameters:
  • fit_function (Callable[[Mapping[str, Any]], FitResult])

  • scenarios (Mapping[str, Mapping[str, Any]])

  • materiality (Mapping[str, float])

  • baseline (str | None)

Return type:

ApproximationSensitivityResult

pymixef.compare.compare(fit, *, reference, mapping=None, conventions=None)[source]

Compare a fit with a reference under matched objective conventions.

Parameter estimates are always aligned independently. Objective differences are calculated only when the reference declares the same method, normalization-constant policy, and objective convention archived by the PyMixEF fit.

Parameters:
  • fit (FitResult)

  • reference (Any)

  • mapping (Mapping[str, str] | None)

  • conventions (Mapping[str, Any] | None)

Return type:

ComparisonResult