Skip to content

Fix overflow in point-set distance norms - #4961

Closed
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/fix-metrics-extreme-norm-20260731
Closed

Fix overflow in point-set distance norms#4961
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/fix-metrics-extreme-norm-20260731

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

What changed

  • replace the overflow-prone built-in Euclidean pairwise norm with scale-normalized norm evaluation
  • keep the correction directly inside src/pyrecest/utils/metrics.py
  • add public OSPA and GOSPA regressions for large finite coordinates

Root cause

_pairwise_distances() delegated directly to np.linalg.norm. For a finite difference vector such as [1e308, 1e308], the internal sum of squares overflows even though the Euclidean norm, approximately 1.4142e308, is representable. OSPA and GOSPA then clip the resulting infinity to the cutoff and overstate localization error whenever the cutoff exceeds the true distance.

Impact

Built-in OSPA/GOSPA distances now preserve representable Euclidean distances at extreme finite coordinate scales. Ordinary-scale behavior and custom distance_fn handling are unchanged.

This replaces the valid bug fix attempted in #4951 with the requested focused implementation: no wrapper module, no duplicated metrics implementation, and no import-time monkey patching.

Validation

  • reproduced the pre-fix overflow under np.errstate(over="raise", invalid="raise")
  • validated both public OSPA and GOSPA calls against np.hypot(1e308, 1e308)
  • syntax-compiled the modified source and regression module
  • branch is current with main; final diff is limited to one in-place source change and one regression file

GitHub Actions provides the full supported-version and backend validation matrix.

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 29.38s
✅ JSON prettier 7 0 0 0 1.31s
✅ JSON v8r 7 0 0 3.32s
✅ MARKDOWN markdownlint 68 0 0 0 2.11s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.71s
✅ PYTHON black 1808 55 0 0 95.4s
✅ PYTHON isort 1808 87 0 0 2.8s
✅ REPOSITORY betterleaks yes no no 2.5s
✅ REPOSITORY checkov yes no no 54.51s
✅ REPOSITORY gitleaks yes no no 17.29s
✅ REPOSITORY git_diff yes no no 0.32s
✅ REPOSITORY secretlint yes no no 82.77s
✅ REPOSITORY syft yes no no 6.17s
✅ REPOSITORY trivy-sbom yes no no 5.58s
✅ REPOSITORY trufflehog yes no no 31.68s
✅ YAML prettier 11 0 0 0 0.82s
✅ YAML v8r 11 0 0 13.07s
✅ YAML yamllint 11 0 0 0.67s

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 low value. This changes core OSPA/GOSPA distance evaluation solely for coordinate differences around 1e308. That scale is not a meaningful supported tracking regime, so the special normalization path and regression surface are not justified.

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