Skip to content

Reject nonsymmetric candidate mixture covariances - #5349

Merged
FlorianPfaff merged 2 commits into
mainfrom
agent/reject-nonsymmetric-candidate-covariances
Aug 18, 2026
Merged

Reject nonsymmetric candidate mixture covariances#5349
FlorianPfaff merged 2 commits into
mainfrom
agent/reject-nonsymmetric-candidate-covariances

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • Reject materially nonsymmetric covariance matrices in GaussianMixtureMeasurementFactor before Cholesky factorization.
  • Preserve tolerance for floating-point-scale skew (relative asymmetry up to 1e-12) and symmetrize only that residual numerical noise.
  • Add regressions for shared covariances, per-component covariances, and tolerated round-off asymmetry.

Bug

GaussianMixtureMeasurementFactor.__post_init__() currently symmetrizes every covariance before checking positive definiteness. An invalid covariance such as

np.array([[2.0, 1.0], [0.0, 2.0]])

is therefore silently replaced by [[2.0, 0.5], [0.5, 2.0]], after which Cholesky succeeds. This changes the caller's measurement-noise model and can alter Mahalanobis distances, component responsibilities, evidence, and moment-matched outputs instead of rejecting invalid input.

Fix

Compare each covariance against its transpose with a scale-aware 1e-12 relative-asymmetry threshold before _symmetrize(). Material asymmetry now raises ValueError("covariances must be symmetric"); only round-off-scale skew is retained for the existing symmetrization step.

Validation

  • Added focused regressions for both broadcast/shared and per-component covariance inputs.
  • Added a regression confirming round-off-scale asymmetry remains accepted and symmetrized.
  • Branch is based on fc15bed910b324cd0619a2f2b71abc887bc09747 and is 2 commits ahead / 0 behind that base.
  • Diff is limited to 11 production additions and one 48-line regression file.
  • Full repository test/backend validation is delegated to GitHub Actions because the execution environment cannot clone the repository over the network and does not have PyRecEst installed.

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 5.91s
✅ JSON prettier 7 0 0 0 0.49s
✅ JSON v8r 7 0 0 3.57s
✅ MARKDOWN markdownlint 68 0 0 0 1.82s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.27s
✅ PYTHON black 1984 10 0 0 46.34s
✅ PYTHON isort 1984 20 0 0 2.15s
✅ REPOSITORY betterleaks yes no no 0.95s
✅ REPOSITORY checkov yes no no 31.28s
✅ REPOSITORY git_diff yes no no 0.09s
✅ REPOSITORY secretlint yes no no 77.14s
✅ REPOSITORY syft yes no no 2.21s
✅ REPOSITORY trivy-sbom yes no no 1.7s
✅ YAML prettier 11 0 0 0 0.42s
✅ YAML v8r 11 0 0 8.51s
✅ YAML yamllint 11 0 0 0.71s

Notices

⚠️ Your configuration references items that have been removed from MegaLinter and are ignored: MAKEFILE_CHECKMAKE. See Removed linters to find their replacements.

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@10.0.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_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review August 18, 2026 19:18
@FlorianPfaff
FlorianPfaff merged commit a989df0 into main Aug 18, 2026
14 of 24 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