Skip to content

Handle batched hypertoroidal nearest-grid queries#4376

Merged
FlorianPfaff merged 2 commits into
mainfrom
agent/fix-hypertoroidal-grid-batch-nearest-20260714
Jul 14, 2026
Merged

Handle batched hypertoroidal nearest-grid queries#4376
FlorianPfaff merged 2 commits into
mainfrom
agent/fix-hypertoroidal-grid-batch-nearest-20260714

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Summary

  • compute nearest custom-grid indices for every hypertoroidal query instead of only the first row
  • return one closest grid point per batched query
  • preserve the existing one-dimensional return shape for a single query
  • document the accepted batched input shape and add a focused regression test

Root cause

HypertoroidalGridDistribution.get_closest_point() builds a full distance matrix with shape (n_eval, n_grid), but then explicitly evaluates only dists[0]. Any additional query rows are silently discarded, so a batched call returns the nearest grid point for only the first query.

Impact

Callers can now pass multiple hypertoroidal query points and receive the corresponding nearest grid point for each one. Existing single-query behavior remains unchanged.

Validation

  • reproduced the old behavior with two distinct toroidal queries: only the first nearest point was returned
  • verified vectorized argmin(..., axis=1) returns [[0, 0], [pi, pi]] for the regression geometry
  • added tests/distributions/test_hypertoroidal_grid_batch_closest.py
  • branch is two commits ahead of current main, zero behind; production diff is 8 additions and 5 deletions

The complete backend matrix is delegated to GitHub Actions.

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 23.63s
✅ JSON prettier 7 0 0 0 1.18s
✅ JSON v8r 7 0 0 4.86s
✅ MARKDOWN markdownlint 68 0 0 0 1.74s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.89s
✅ PYTHON black 1490 182 0 0 94.99s
✅ PYTHON isort 1490 328 0 0 2.67s
✅ REPOSITORY betterleaks yes no no 2.48s
✅ REPOSITORY checkov yes no no 54.45s
✅ REPOSITORY gitleaks yes no no 14.73s
✅ REPOSITORY git_diff yes no no 0.37s
✅ REPOSITORY secretlint yes no no 62.3s
✅ REPOSITORY syft yes no no 5.22s
✅ REPOSITORY trivy-sbom yes no no 6.66s
✅ REPOSITORY trufflehog yes no no 31.58s
✅ YAML prettier 11 0 0 0 0.72s
✅ YAML v8r 11 0 0 12.07s
✅ YAML yamllint 11 0 0 0.47s

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 July 14, 2026 20:13
@FlorianPfaff FlorianPfaff merged commit 235010f into main Jul 14, 2026
26 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