Skip to content

Fix hyperhemisphere component state assignment - #5260

Open
FlorianPfaff wants to merge 3 commits into
mainfrom
agent/fix-hyperhemisphere-component-state-assignment
Open

Fix hyperhemisphere component state assignment#5260
FlorianPfaff wants to merge 3 commits into
mainfrom
agent/fix-hyperhemisphere-component-state-assignment

Conversation

@FlorianPfaff

@FlorianPfaff FlorianPfaff commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Bug

HyperhemisphereCartProdParticleFilter had two inconsistent paths for assigning a single hyperhemispherical component distribution to a Cartesian-product particle filter.

The filter_state property setter correctly sampled n_particles * n_hemispheres component vectors before reshaping them into the product state. However, set_state(...) bypassed that path and sampled only n_particles vectors, then tried to construct a product distribution from the single-component-width array. For filters with more than one hemisphere this raises ValueError: Dimension is not correct. instead of assigning the distribution across all components.

The specialized filter_state setter also replaced particle locations without resetting particle weights. That differs from the base AbstractParticleFilter.filter_state contract, which resets weights to uniform whenever a new continuous distribution is sampled into the particle state. A prior nonuniform posterior could therefore leak stale weights into a newly sampled state.

Fix

  • route non-product set_state(...) assignments through the existing product-aware filter_state setter;
  • reset particle weights to uniform after sampling a hyperhemispherical/hyperspherical distribution, matching the base particle-filter assignment semantics;
  • use backend ones_like(...) for the reset so weight dtype/device are preserved.

Regression coverage

Add focused NumPy-backend tests that verify:

  • set_state(...) expands a single HyperhemisphericalWatsonDistribution across both product components without a shape error;
  • the resulting product state has shape (n_particles, n_hemispheres * (dim_hemisphere + 1));
  • samples remain on the upper hemisphere;
  • both set_state(...) and direct filter_state = distribution assignment reset stale nonuniform weights to uniform.

Validation

  • branch is based directly on current main (f196ec41d1d8681e279936db9f1a0a3abfa276e7);
  • branch is 3 commits ahead / 0 behind;
  • diff is limited to the hyperhemisphere Cartesian-product particle filter and one focused regression module;
  • focused Ruff validation passed on the first PR head; GitHub Actions is authoritative for the full backend, packaging, documentation, security, and integration matrix.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 24.71s
✅ JSON prettier 7 0 0 0 1.34s
✅ JSON v8r 7 0 0 4.96s
✅ MARKDOWN markdownlint 68 0 0 0 2.0s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.74s
✅ PYTHON black 1867 88 0 0 95.02s
✅ PYTHON isort 1867 141 0 0 2.79s
✅ REPOSITORY betterleaks yes no no 2.77s
✅ REPOSITORY checkov yes no no 56.51s
✅ REPOSITORY gitleaks yes no no 17.63s
✅ REPOSITORY git_diff yes no no 0.44s
✅ REPOSITORY secretlint yes no no 87.14s
✅ REPOSITORY syft yes no no 5.55s
✅ REPOSITORY trivy-sbom yes no no 5.6s
✅ REPOSITORY trufflehog yes no no 32.45s
✅ YAML prettier 11 0 0 0 0.78s
✅ YAML v8r 11 0 0 11.97s
✅ 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

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review August 7, 2026 17:52
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) August 7, 2026 17:52
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