Skip to content

LC2ST_NF does not honor the LC2ST method contract #2005

Description

@janfb

LC2ST_NF subclasses LC2ST, but its evaluation methods have a different contract. In LC2ST, theta_o are posterior samples at x_o. In LC2ST_NF, evaluation runs in the flow's base space on samples drawn once in __init__. The class docstring says so: no theta_o is passed to the evaluation functions.

The five overrides (get_scores, get_statistic_on_observed_data, p_value, reject_test, get_statistics_under_null_hypothesis) therefore drop theta_o. Pyright flags them under reportIncompatibleMethodOverride, see #1979.

A signature patch does not fix this. #1984 tried it: theta_o becomes an ignored parameter, x_o needs a None default plus a guard, and positional x_o calls break. We dropped that part of the PR.

The fix is structural. I see two options:

  • Composition: LC2ST_NF holds an LC2ST and exposes its own (x_o, ...) API.
  • A shared private base for the training and null machinery. LC2ST and LC2ST_NF each define their own public evaluation methods on top.

Both change the public hierarchy, isinstance(lc2st_nf, LC2ST) stops being true, so this needs a deprecation note.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    API changesThis impacts the public API of the project (e.g. inference class).architectureInternal structure and design of the codebaseblockedSomething is in the way of fixing this. Refer to it in the issuediagnosticsSBC, TARP, L-C2ST, coverage, sensitivity analysis, and plots

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions