Skip to content

fix(autocorr,clt): NaN-safe guards and finite inputs (#46) - #47

Merged
marcohost33-maker merged 4 commits into
mainfrom
fix/issue46-nan-guards
Sep 26, 2026
Merged

marcohost33-maker merged 4 commits into
mainfrom
fix/issue46-nan-guards

Conversation

@marcohost33-maker

@marcohost33-maker marcohost33-maker commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Closes #46.

Guards of the form if stat <= 0: raise rejected only when an ordered comparison was True, so NaN passed and produced silent NaN results. Found by the NaN-orientation lint (nan-gate-lint.py 1.0.1, Vero tools).

Correction (after the independent round on 4436c1e): the first version of this PR claimed that finiteness checked in autocorr_function_fft reached binning_error — that was wrong, binning_error never calls it, and further public entries still returned NaN silently (obm_variance, jackknife_ratio, integrated_autocorr_time(..., rho=...), ar1_clt_variance(sigma_eps=nan), confidence_interval(n=nan)). The PR now checks every public entry.

Changes

  • autocorr._require_finite(values, name): fail closed on NaN/inf, called at each public entry: autocorr_function_fft, integrated_autocorr_time (samples always, and a precomputed rho), binning_error, jackknife_ratio (numerator and denominator terms), clt.obm_variance.
  • positively formulated guards: var0, c_window, sigma2_g (finite and ≥ 0), mean finite, ar1_clt_variance sigma_eps finite and > 0, confidence_interval n NaN-safe.
  • an overflowing series (|x| ≈ 1e308, finite samples) now reports "variance overflows float64" instead of the misleading "constant series".

Evidence (Windows, py3.12) at 496747c

  • 20 new cases red on the base (10 in 6d445d5, 10 in 706bfbf), all by assertion
  • test_autocorr + test_clt: 60 passed; indirect consumers (test_checkpoint, test_manifest, test_mcrg*, test_rbim_nishimori, test_snis, test_wolff2d + the two): 181 passed, exit 0
  • python -m adaptiverg_qec.cli --selftest --json results/selftest-ci.json: 45/45 PASS, exit 0 (exit measured directly, not through a pipe)
  • ruff check + ruff format --check clean
  • diskriminierung.py: DK-20260926T102148-f647563dbe6a (first four guards) and DK-20260926T112239-2956ffa7d19a (8/8 new guards: binning, rho-path x, rho finite, jackknife, overflow message, obm, sigma_eps, n); positive control on a normal-path test collapsed as required (DK-20260926T112337-292c42f43469)

Pre-existing, not changed here: callers in mcrg_matrix.py/mcrg_multirg.py pre-check np.var(x) > 0, so a NaN series never reaches autocorr there and tau silently becomes 0.5 — tracked as follow-up.

🤖 Generated with Claude Code

marcohost33-maker and others added 2 commits September 26, 2026 12:21
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…undary (#46)

var0 <= 0.0 and sigma2_g < 0.0 rejected only when an ordered comparison was
True, so NaN passed and produced all-NaN results. Samples, c_window, mean
and sigma2_g are now checked with positively formulated, finite conditions.
Found by nan-gate-lint (Vero tools).

Closes #46

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

marcohost33-maker and others added 2 commits September 26, 2026 13:22
Review of #47 found that binning_error, obm_variance, jackknife_ratio, the
precomputed-rho path, ar1_clt_variance(sigma_eps) and confidence_interval(n)
still returned NaN silently, and an overflowing series was reported as
'constant'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…te (#46)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@marcohost33-maker

Copy link
Copy Markdown
Owner Author

Delta round (Equalita, same family) at 496747c: PASS WITH CONDITIONS (P3 only). NaN/+inf/-inf now fail loudly at all 15 array entries (autocorr.py:89/162/169/254/345-346, clt.py:136); integer arrays, lists, unmasked np.ma, np.int64 sizes and empty arrays still behave; no circular import (5 import orders). All body numbers reproduced by the reviewer: 60 / 181 passed, selftest 45/45 exit 0, 20 red on the bases. Discrimination DK-20260926T114219-9018dfa66a5c + positive control DK-20260926T114305-b34c91bbab56.

Precision of my body: in run DK-…112239 my first positive-control case was blind (it targeted a test that expects the raise) — replaced by a normal-path control (DK-…112337); 'jackknife' there discriminates the num guard only — the den_terms guard has no test (P3-1). Follow-ups moved to #48: den=NaN test, +inf for c_window and n (c_window=+inf → tau 1.40 instead of 9.26 at phi 0.9), non-finite results from finite |x|≈1e308 in binning_error/obm_variance, rho shape unchecked.

🤖 Generated with Claude Code

@marcohost33-maker
marcohost33-maker merged commit 9de9187 into main Sep 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NaN passes two rejection guards (autocorr var0, clt sigma2_g): fail-open orientation

1 participant