Fix PyTorch symmetric Leopardi collar dtype - #5381
Merged
Merged
Conversation
Contributor
✅MegaLinter analysis: Success
Notices
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
|
FlorianPfaff
marked this pull request as ready for review
August 21, 2026 06:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fix the PyTorch regression in symmetric Leopardi small-grid partitioning.
The existing regression
tests/test_leopardi_symmetric_small_grid.py::test_symmetric_four_point_partition_uses_two_collarsfails in the current Python 3.13 PyTorch CI matrix:
get_equal_area_caps(2, 4, symmetric=True)returns region counts[3, 1, 1, 1]instead of the intended[1, 1, 1, 1].Root cause
PR #5202 fixed small symmetric partitions by making the half-collar count an explicitly integer backend array:
The later compatibility wrapper in
src/pyrecest/sampling/leopardi_sampler/__init__.pyreimplemented that logic but omitteddtype=int32. On PyTorch the tuple mixes the Python integer lower bound with a floating backend result fromround(ratio_half), so the construction is promoted away from the discrete collar-count contract.Fix
Restore the explicit backend
int32dtype in the compatibility wrapper, matching the canonical implementation already present inleopardi_sampler.pyand the fix originally merged in #5202.No partition formulas or public API are changed.
Evidence
32406079884on a current-main-based branch.mainatb7d3edc9ac05600de5345dc20fd6f3db33154d86.