Skip to content

Preserve hypertoroidal particle counts and axes - #5262

Open
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/fix-hypertoroidal-particle-count
Open

Preserve hypertoroidal particle counts and axes#5262
FlorianPfaff wants to merge 2 commits into
mainfrom
agent/fix-hypertoroidal-particle-count

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Bug

HypertoroidalParticleFilter initialized multidimensional particles with a floating-step arange(...) and then applied .squeeze().

This violates the constructor's particle-count and shape contracts in two concrete cases:

  • floating-point rounding can include the nominal endpoint. For n_particles=61 and dim=2, NumPy produces 62 grid values, with the final value equal to ; after toroidal wrapping this is a duplicate of zero;
  • for n_particles=1 and dim>1, .squeeze() removes the particle axis, so one three-dimensional particle is stored as shape (3,) instead of (1, 3). The shared Dirac constructor then interprets the state as three scalar Diracs and creates three weights.

Fix

Generate the one-dimensional angular grid with exact-count linspace(..., num=n_particles, endpoint=False) for every dimension. For multidimensional filters, tile and transpose that grid without squeezing the batch axis.

Regression coverage

  • verify that requesting 61 two-dimensional particles creates state shape (61, 2) and 61 weights;
  • verify that one three-dimensional particle preserves state shape (1, 3), one weight, and a three-dimensional point estimate.

Validation

  • independently reproduced the old 61-particle grid as 62 values, including the nominal endpoint;
  • independently reproduced the singleton construction collapsing (1, 3) to (3,);
  • refreshed the branch directly onto current main (f196ec41d1d8681e279936db9f1a0a3abfa276e7);
  • branch comparison is 2 commits ahead / 0 behind;
  • final diff is limited to 8 changed implementation lines and 13 regression-test additions;
  • the prior version of this focused patch passed MegaLinter; GitHub Actions on the refreshed head is authoritative for the full repository 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 19.4s
✅ JSON prettier 7 0 0 0 1.05s
✅ JSON v8r 7 0 0 2.14s
✅ MARKDOWN markdownlint 68 0 0 0 1.5s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.5s
✅ PYTHON black 1866 87 0 0 69.57s
✅ PYTHON isort 1866 140 0 0 2.17s
✅ REPOSITORY betterleaks yes no no 1.83s
✅ REPOSITORY checkov yes no no 43.08s
✅ REPOSITORY gitleaks yes no no 14.41s
✅ REPOSITORY git_diff yes no no 0.15s
✅ REPOSITORY secretlint yes no no 64.25s
✅ REPOSITORY syft yes no no 3.83s
✅ REPOSITORY trivy-sbom yes no no 5.04s
✅ REPOSITORY trufflehog yes no no 23.93s
✅ YAML prettier 11 0 0 0 0.6s
✅ YAML v8r 11 0 0 9.23s
✅ YAML yamllint 11 0 0 0.41s

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 enabled auto-merge (squash) August 7, 2026 17:51
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