Skip to content

Avoid overflow when validating SO(3) product particles - #5241

Open
FlorianPfaff wants to merge 1 commit into
mainfrom
agent/fix-so3-product-extreme-quaternion-normalization
Open

Avoid overflow when validating SO(3) product particles#5241
FlorianPfaff wants to merge 1 commit into
mainfrom
agent/fix-so3-product-extreme-quaternion-normalization

Conversation

@FlorianPfaff

@FlorianPfaff FlorianPfaff commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace the raw Euclidean-norm nonzero check for SO(3) product particles with a componentwise nonzero check
  • preserve rejection of zero quaternions while allowing the existing scale-first quaternion normalizer to handle extreme finite magnitudes
  • add a regression using backend-dtype quaternions with components at half the largest finite value

Bug

SO3ProductParticleFilter._as_particle_array checked whether a quaternion was nonzero using linalg.norm. For a valid finite quaternion such as [float_max / 2, float_max / 2, 0, 0], the intermediate sum of squares overflows. Under strict NumPy floating-point handling this raises before PyRecEst's existing overflow-safe normalize_quaternions helper can run.

The quaternion's scale is irrelevant to the represented rotation, so rejecting it is incorrect.

Fix

Use a componentwise nonzero predicate for validation. This avoids squaring the input and leaves normalization to the existing scale-first helper.

Validation

  • isolated reproduction: the old raw norm raises FloatingPointError: overflow encountered in multiply
  • patched path: the same finite quaternion normalizes to [1/sqrt(2), 1/sqrt(2), 0, 0] with unit norm under strict floating-point settings
  • focused Ruff, documentation, security, dependency-review, and package smoke checks passed on the reviewed diff before history cleanup
  • the branch now contains one intentional commit; repository CI is rerunning on that final head

Use a componentwise nonzero check before the existing scale-first quaternion normalizer, and cover extreme finite quaternion inputs with a regression test.
@FlorianPfaff
FlorianPfaff force-pushed the agent/fix-so3-product-extreme-quaternion-normalization branch from e5d27e0 to 13c1e1e Compare August 6, 2026 06:46
@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 18.94s
✅ JSON prettier 7 0 0 0 0.72s
✅ JSON v8r 7 0 0 3.02s
✅ MARKDOWN markdownlint 68 0 0 0 1.7s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.93s
✅ PYTHON black 1866 88 0 0 69.3s
✅ PYTHON isort 1866 140 0 0 2.13s
✅ REPOSITORY betterleaks yes no no 1.51s
✅ REPOSITORY checkov yes no no 42.19s
✅ REPOSITORY gitleaks yes no no 13.5s
✅ REPOSITORY git_diff yes no no 0.26s
✅ REPOSITORY secretlint yes no no 60.68s
✅ REPOSITORY syft yes no no 4.18s
✅ REPOSITORY trivy-sbom yes no no 4.23s
✅ REPOSITORY trufflehog yes no no 24.26s
✅ YAML prettier 11 0 0 0 0.56s
✅ YAML v8r 11 0 0 9.32s
✅ YAML yamllint 11 0 0 0.61s

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:58
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 7, 2026 17:58
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