fix(mask): cap radius under PYAUTO_SMALL_DATASETS#325
Merged
Conversation
Mask2D.circular already clamps shape_native and pixel_scales when PYAUTO_SMALL_DATASETS=1, but left radius untouched. Group SLaM scripts asking for radius=6.0-7.5 inside the post-clamp 15x15/0.6 grid silently received a fully-unmasked square, which the post-cef28716 strict is_circular correctly rejected — causing Hilbert image-mesh to raise PixelizationException. Cap radius to min(shape_native) * pixel_scales / 2.0 (handling both float and tuple pixel_scales). Three tests added: oversized clamps, in-bounds passes through, tuple-scales path covered. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
When
PYAUTO_SMALL_DATASETS=1,Mask2D.circularclampedshape_nativeto(15, 15)andpixel_scalesto0.6but leftradiusuntouched. Callers asking forradiuslarger than the post-clamp grid half-extent silently received a fully-unmasked 15×15 square instead of a circular disc.After
cef28716tightenedis_circular, this surfaced as aPixelizationExceptionfrom Hilbert image-mesh in two group SLaM scripts (group/features/{linear_light_profiles,no_lens_light}/slam.py). The cluster's prescribed root cause ("scripts pass a non-circular mask") was misleading — both scripts already useMask2D.circular; the fault was in the small-datasets shim.API Changes
None — internal behaviour change only. Under
PYAUTO_SMALL_DATASETS=1,Mask2D.circularnow also clampsradiustomin(shape_native) * pixel_scales / 2.0. Outside that env var the function is unchanged.See full details below.
Test Plan
pytest test_autoarray/mask/test_mask_2d.py— 59 passed (3 new tests)PYAUTO_SMALL_DATASETS=1 PYAUTO_TEST_MODE=2 ... python scripts/group/features/no_lens_light/slam.py— completes 4 searches end-to-end (was raisingPixelizationException)PYAUTO_SMALL_DATASETS=1 PYAUTO_TEST_MODE=2 ... python scripts/group/features/linear_light_profiles/slam.py— completes 6 searches end-to-end (was raisingPixelizationException)Full API Changes (for automation & release notes)
Changed Behaviour
Mask2D.circular(shape_native, pixel_scales, radius, ...)— whenPYAUTO_SMALL_DATASETS=1,radiusis now clamped tomin(shape_native) * pixel_scales / 2.0. No effect outside the env var; no effect whenradiusalready fits.Not Changed
Mask2D.circular_annular,Mask2D.elliptical,Mask2D.elliptical_annularcarry the same latent overflow pattern but are untouched here — no failing cluster exercises them. Same fix can be applied if/when needed.🤖 Generated with Claude Code