Skip to content

Avoid overflow when symmetrizing ellipse matrices - #5217

Closed
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/fix-ellipse-symmetrization-overflow
Closed

Avoid overflow when symmetrizing ellipse matrices#5217
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/fix-ellipse-symmetrization-overflow

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • avoid intermediate overflow in the shared ellipse-geometry symmetrization helper
  • add a focused float32 regression test that treats overflow/invalid warnings as errors

Bug

0.5 * (matrix + matrix.T) adds the two full-magnitude operands before scaling. For finite float32 entries near finfo.max, that intermediate addition overflows to infinity even when the symmetric average is exactly representable.

Fix

Scale each operand before adding: 0.5 * matrix + 0.5 * matrix.T.

Validation

  • reproduced the old failure with a float32 matrix filled with np.finfo(np.float32).max
  • verified the revised expression returns the unchanged finite matrix under np.errstate(over="raise", invalid="raise")
  • added tests/tracking/test_ellipse_geometry_symmetrization_overflow.py

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 24.03s
✅ JSON prettier 7 0 0 0 1.05s
✅ JSON v8r 7 0 0 4.22s
✅ MARKDOWN markdownlint 68 0 0 0 1.76s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.9s
✅ PYTHON black 1866 87 0 0 89.66s
✅ PYTHON isort 1866 140 0 0 2.76s
✅ REPOSITORY betterleaks yes no no 2.52s
✅ REPOSITORY checkov yes no no 52.05s
✅ REPOSITORY gitleaks yes no no 17.28s
✅ REPOSITORY git_diff yes no no 0.26s
✅ REPOSITORY secretlint yes no no 81.33s
✅ REPOSITORY syft yes no no 5.2s
✅ REPOSITORY trivy-sbom yes no no 6.37s
✅ REPOSITORY trufflehog yes no no 30.76s
✅ YAML prettier 11 0 0 0 0.8s
✅ YAML v8r 11 0 0 11.16s
✅ YAML yamllint 11 0 0 0.53s

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

Copy link
Copy Markdown
Owner Author

Closing as an exact duplicate of #5178. Both replace 0.5 * (matrix + matrix.T) with 0.5 * matrix + 0.5 * matrix.T; #5178 is the earlier PR and already carries equivalent regression coverage.

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