Skip to content

Stabilize DVS polarity sign inference - #5245

Open
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/stabilize-dvs-polarity-inference
Open

Stabilize DVS polarity sign inference#5245
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/stabilize-dvs-polarity-inference

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Bug

infer_polarity_contrast_sign(...) accumulated signed normal-flow evidence directly in an unscaled floating-point scalar.

For large but finite, cancelling flow batches, the partial sum can overflow to infinity even though the final mathematical score is finite. Once the accumulator reaches inf, later opposing evidence cannot recover it, so the inferred polarity-contrast sign can be wrong.

A concrete finite batch proportional to [0.75, 0.75, -0.75, -0.9] * finfo(float).max has a negative total score, while the previous sequential accumulation overflowed after the first two entries and returned +1.

Fix

  • collect the informative signed polarity contributions;
  • scale them by the largest absolute contribution before summation;
  • use math.fsum for accurate cancellation;
  • compare the scaled score against the correspondingly scaled zero tolerance;
  • preserve the existing +1 fallback when all evidence is zero or numerically inconclusive.

Regression coverage

Add a focused extreme-value test under strict NumPy overflow/invalid handling. It verifies that the finite cancelling batch is inferred as -1 rather than being dominated by an overflowed positive partial sum.

Validation

  • reproduced the previous accumulator result as inf for a batch whose scaled sum is -1/6;
  • verified the scaled summation returns the negative sign;
  • branch comparison: 2 commits ahead and 0 behind main;
  • diff is limited to 15 additions / 4 deletions in the implementation and one 11-line regression test.

GitHub Actions is authoritative for the full test, lint, packaging, and integration matrix.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 31.73s
✅ JSON prettier 7 0 0 0 1.09s
✅ JSON v8r 7 0 0 4.07s
✅ MARKDOWN markdownlint 68 0 0 0 1.94s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.6s
✅ PYTHON black 1865 88 0 0 99.79s
✅ PYTHON isort 1865 140 0 0 2.91s
✅ REPOSITORY betterleaks yes no no 2.88s
✅ REPOSITORY checkov yes no no 51.99s
✅ REPOSITORY gitleaks yes no no 17.77s
✅ REPOSITORY git_diff yes no no 0.42s
✅ REPOSITORY secretlint yes no no 83.76s
✅ REPOSITORY syft yes no no 5.47s
✅ REPOSITORY trivy-sbom yes no no 7.28s
✅ REPOSITORY trufflehog yes no no 33.18s
✅ YAML prettier 11 0 0 0 0.8s
✅ YAML v8r 11 0 0 12.39s
✅ YAML yamllint 11 0 0 0.7s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.6.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review August 7, 2026 17:57
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 7, 2026 17:57
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.

1 participant