sbi-dev / sbi-dev/sbi

`LC2ST_NF` does not honor the `LC2ST` method contract

Open
#2,005 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

API changes architecture blocked diagnostics
Dominant language
Python
Stars
865
Forks
260
Avg merge
4d 3h
Merged PRs (30d)
5

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the LC2ST and LC2ST_NF evaluation methods: get_scores, get_statistic_on_observed_data, p_value, reject_test, and get_statistics_under_null_hypothesis. Compare their contracts and the Pyright error from #1979, then choose a hierarchy or composition design that preserves each public API. Done means the overrides are compatible, positional x_o calls remain valid, and the isinstance change has a deprecation note.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.