Repository navigation
Reject non-finite function values in second_autocorr_ineq - #7
Merged
HenriqueAssumpcao merged 2 commits intoOct 29, 2026
Merged
HenriqueAssumpcao merged 2 commits into
HenriqueAssumpcao merged 2 commits into
Conversation
The evaluator only checked for negative values, so NaN and infinity passed every guard (NaN comparisons are False) and were written to the results file as a completed c2. Reject non-finite values before the non-negativity check, with regression tests for NaN, +inf and -inf.
Collaborator
|
Thanks for the contribution! Would you mind updating the PR to include just the new test? PR #8 already applies the same fix. Cheers! |
…p regression test
Contributor
Author
|
Done — merged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
second_autocorr_ineq/input/evaluate.pyacceptsNaN/+inffunction values and writes a result with"c2": NaNinstead of failing. The issue reproducer returns no exception and records the run as completed. Fixes #6.Root cause
The only input guards are
f_values < -1e-6(False for NaN),np.maximum(f_values, 0.0)(keeps NaN), andnorm_1 * norm_inf < 1e-12(False for NaN), so non-finite values pass every check and reach the JSON output.Fix
Reject non-finite values with
np.isfinite(f_values).all()before the non-negativity check.-infwas previously rejected indirectly as negative; it now fails with the same explicit "must be finite" error.Testing
tests/test_second_autocorr_ineq_evaluate.py: NaN,+infand-infprograms raiseValueErrorand write no results file; a finite function still evaluates (c2 = 2/3for[1, 1, 1, 1]).pytest tests/test_second_autocorr_ineq_evaluate.py→ 4 passed.ValueError: Function values must be finite.instead of writing NaN.