Skip to content

Guard undefined hyperspherical mean directions#2077

Merged
FlorianPfaff merged 6 commits into
mainfrom
fix-undefined-mean-direction
May 18, 2026
Merged

Guard undefined hyperspherical mean directions#2077
FlorianPfaff merged 6 commits into
mainfrom
fix-undefined-mean-direction

Conversation

@FlorianPfaff
Copy link
Copy Markdown
Owner

Summary

  • raise ValueError instead of normalizing a near-zero first moment in hyperspherical mean-direction computations
  • apply the same guard to the hyperhemispherical numerical override
  • add a regression test for the uniform circle, whose full-sphere mean direction is undefined

Rationale

For distributions with a zero or near-zero first moment, such as the full-circle uniform distribution, the mean direction is mathematically undefined. Previously the implementation emitted a warning and then divided by the near-zero norm anyway, which could yield NaNs or meaningless directions.

Testing

  • Not run locally in this environment; changes are covered by a targeted regression test added to tests/distributions/test_abstract_hyperspherical_distribution.py.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Test Results

    12 files  ± 0      12 suites  ±0   2h 22m 59s ⏱️ + 10m 9s
 1 834 tests + 1   1 833 ✅ +1      1 💤 ±0  0 ❌ ±0 
22 520 runs  +12  17 952 ✅ +8  4 568 💤 +4  0 ❌ ±0 

Results for commit 3b5f398. ± Comparison against base commit 7f90866.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 22.13s
✅ JSON prettier 2 0 0 0 0.45s
✅ JSON v8r 2 0 0 3.01s
✅ MARKDOWN markdownlint 28 0 0 0 1.45s
✅ MARKDOWN markdown-table-formatter 28 0 0 0 0.36s
✅ PYTHON bandit 571 0 0 10.18s
✅ PYTHON black 571 29 0 0 19.28s
✅ PYTHON flake8 571 0 0 6.33s
✅ PYTHON isort 571 30 0 0 1.1s
✅ PYTHON mypy 571 0 0 7.81s
✅ PYTHON pylint 571 0 0 106.98s
✅ PYTHON ruff 571 30 0 0 0.13s
✅ REPOSITORY checkov yes no no 27.68s
✅ REPOSITORY gitleaks yes no no 15.83s
✅ REPOSITORY git_diff yes no no 0.09s
✅ REPOSITORY osv-scanner yes no no 1.25s
✅ REPOSITORY secretlint yes no no 10.26s
✅ REPOSITORY syft yes no no 2.75s
✅ REPOSITORY trivy-sbom yes no no 4.05s
✅ REPOSITORY trufflehog yes no no 22.92s
✅ YAML prettier 5 0 0 0 0.54s
✅ YAML v8r 5 0 0 5.41s
✅ YAML yamllint 5 0 0 0.49s

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.5.0 --custom-flavor-setup --custom-flavor-linters PYTHON_PYLINT,PYTHON_BLACK,PYTHON_FLAKE8,PYTHON_ISORT,PYTHON_BANDIT,PYTHON_MYPY,PYTHON_RUFF,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_OSV_SCANNER,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 and others added 3 commits May 18, 2026 13:53
…rection

# Conflicts:
#	src/pyrecest/distributions/hypersphere_subset/abstract_hyperhemispherical_distribution.py
#	src/pyrecest/distributions/hypersphere_subset/abstract_hypersphere_subset_distribution.py
@FlorianPfaff FlorianPfaff merged commit 6be2623 into main May 18, 2026
20 checks passed
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