Skip to content

fix(mask): cap radius under PYAUTO_SMALL_DATASETS#325

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/small-datasets-mask-radius-cap
May 20, 2026
Merged

fix(mask): cap radius under PYAUTO_SMALL_DATASETS#325
Jammy2211 merged 1 commit into
mainfrom
feature/small-datasets-mask-radius-cap

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

When PYAUTO_SMALL_DATASETS=1, Mask2D.circular clamped shape_native to (15, 15) and pixel_scales to 0.6 but left radius untouched. Callers asking for radius larger than the post-clamp grid half-extent silently received a fully-unmasked 15×15 square instead of a circular disc.

After cef28716 tightened is_circular, this surfaced as a PixelizationException from 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 use Mask2D.circular; the fault was in the small-datasets shim.

API Changes

None — internal behaviour change only. Under PYAUTO_SMALL_DATASETS=1, Mask2D.circular now also clamps radius to min(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 raising PixelizationException)
  • PYAUTO_SMALL_DATASETS=1 PYAUTO_TEST_MODE=2 ... python scripts/group/features/linear_light_profiles/slam.py — completes 6 searches end-to-end (was raising PixelizationException)
Full API Changes (for automation & release notes)

Changed Behaviour

  • Mask2D.circular(shape_native, pixel_scales, radius, ...) — when PYAUTO_SMALL_DATASETS=1, radius is now clamped to min(shape_native) * pixel_scales / 2.0. No effect outside the env var; no effect when radius already fits.

Not Changed

  • Mask2D.circular_annular, Mask2D.elliptical, Mask2D.elliptical_annular carry 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

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>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 20, 2026
@Jammy2211 Jammy2211 merged commit 4512557 into main May 20, 2026
6 checks passed
@Jammy2211 Jammy2211 deleted the feature/small-datasets-mask-radius-cap branch May 20, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-release PR queued for the next release build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant