Skip to content

Stabilize Euclidean MTT distances at extreme scales - #4968

Closed
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/stabilize-euclidean-mtt-extreme-norms
Closed

Stabilize Euclidean MTT distances at extreme scales#4968
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/stabilize-euclidean-mtt-extreme-norms

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • compute Euclidean MTT pairwise norms with numpy.hypot.reduce instead of numpy.linalg.norm
  • preserve finite localization distances when coordinate magnitudes are close to the float64 limit
  • add a focused regression that runs with floating-point overflow configured to raise

Bug

_euclidean_mtt_distance() formed finite displacement vectors and evaluated them with numpy.linalg.norm. For a displacement such as [1e308, 1e308], the mathematically correct norm is approximately 1.4142e308 and is still representable, but numpy.linalg.norm squares the components internally and overflows to infinity.

With a cutoff of 1.5e308, the overflow caused the pairwise cost to be clipped to 1.5e308, overstating the localization error. Under numpy.errstate(over="raise"), the same valid input raised FloatingPointError.

Fix

Use numpy.hypot.reduce(..., axis=2), which accumulates Euclidean norms with scale-aware arithmetic and returns the correct finite value without an overflowing square.

Validation

  • reproduced the old result: 1.5e308 after erroneous cutoff clipping
  • verified the patched calculation returns 1.4142135623730951e308
  • verified the patched path succeeds under numpy.errstate(over="raise", invalid="raise")
  • added a regression to tests/evaluation/test_euclidean_mtt_distance_orientation.py
  • branch is 2 commits ahead of and 0 behind current main; the diff contains only the implementation line and focused test

Full repository tests were not run locally because this environment could not resolve GitHub for a checkout; GitHub Actions should exercise the in-tree regression and full matrix.

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 13.8s
✅ JSON prettier 7 0 0 0 0.59s
✅ JSON v8r 7 0 0 3.48s
✅ MARKDOWN markdownlint 68 0 0 0 1.01s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.53s
✅ PYTHON black 1809 56 0 0 52.71s
✅ PYTHON isort 1809 88 0 0 1.45s
✅ REPOSITORY betterleaks yes no no 1.3s
✅ REPOSITORY checkov yes no no 36.84s
✅ REPOSITORY gitleaks yes no no 8.83s
✅ REPOSITORY git_diff yes no no 0.15s
✅ REPOSITORY secretlint yes no no 44.54s
✅ REPOSITORY syft yes no no 2.97s
✅ REPOSITORY trivy-sbom yes no no 2.61s
✅ REPOSITORY trufflehog yes no no 20.02s
✅ YAML prettier 11 0 0 0 0.5s
✅ YAML v8r 11 0 0 7.2s
✅ YAML yamllint 11 0 0 0.29s

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/incomplete. It targets Euclidean MTT coordinates near the float64 limit (around 1e308), outside a practical tracking regime, while replacing the reduction without an initial value can also change behavior for zero-dimensional target states. The edge case does not justify that regression risk.

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