Skip to content

Reject broadcast process covariance in UKF prediction - #5194

Closed
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/reject-broadcast-ukf-process-covariance-20260805
Closed

Reject broadcast process covariance in UKF prediction#5194
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/reject-broadcast-ukf-process-covariance-20260805

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Bug

The low-level unscented Kalman filter added self.Q directly to the predicted covariance without validating its matrix shape.

For a two-dimensional state, a vector such as Q = [0.4, 0.2] was therefore broadcast across the covariance matrix by NumPy. After the existing symmetrization step, an identity prediction silently produced a spurious cross-covariance of 0.3 instead of rejecting the malformed process-noise input.

Fix

Convert the configured process covariance once, require the exact (dim_x, dim_x) shape, and reuse that validated matrix in the covariance update. Validation happens before filter-state mutation.

Regression coverage

The new public regression verifies that a vector-valued process covariance:

  • raises a clear ValueError;
  • does not mutate the state mean;
  • does not mutate the state covariance.

Validation

  • python -m py_compile passed for the modified implementation and regression module;
  • isolated NumPy reproduction confirmed the previous vector broadcast introduced a 0.3 off-diagonal covariance;
  • branch comparison: 2 commits ahead, 0 behind current main;
  • final diff is limited to the UKF process-covariance shape guard and one focused regression module.

GitHub Actions is the authoritative full backend, lint, packaging, documentation, and integration validation.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 23.66s
✅ JSON prettier 7 0 0 0 1.42s
✅ JSON v8r 7 0 0 4.47s
✅ MARKDOWN markdownlint 68 0 0 0 1.96s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.8s
✅ PYTHON black 1866 87 0 0 90.97s
✅ PYTHON isort 1866 139 0 0 2.75s
✅ REPOSITORY betterleaks yes no no 2.06s
✅ REPOSITORY checkov yes no no 52.35s
✅ REPOSITORY gitleaks yes no no 16.75s
✅ REPOSITORY git_diff yes no no 0.2s
✅ REPOSITORY secretlint yes no no 81.2s
✅ REPOSITORY syft yes no no 5.57s
✅ REPOSITORY trivy-sbom yes no no 5.62s
✅ REPOSITORY trufflehog yes no no 31.06s
✅ YAML prettier 11 0 0 0 0.86s
✅ YAML v8r 11 0 0 11.53s
✅ YAML yamllint 11 0 0 0.63s

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 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing as superseded by #5253. Both PRs address the same malformed multidimensional UKF process-noise covariance broadcasting bug; #5253 is the refreshed current-main version and explicitly retains the one-dimensional scalar/length-one shorthand plus atomic state preservation. Keeping both open would duplicate review and CI work.

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