Skip to content

test: regression guard for HowToLens tutorial_3 NaN axis-limits crash#560

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/howtolens-tutorial3-nan-axis-test
May 29, 2026
Merged

test: regression guard for HowToLens tutorial_3 NaN axis-limits crash#560
Jammy2211 merged 1 commit into
mainfrom
feature/howtolens-tutorial3-nan-axis-test

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

Regression test locking in the fix for the HowToLens chapter-1
tutorial_3_more_ray_tracing crash: ValueError: Axis limits cannot be NaN or Inf during plotting.

The crash no longer reproduces on main — it was fixed producer-side (mass
profile deflections now handle r = 0; cf. autogalaxy 398f7417 "handle r=0 in
NFWSph deflections" and 8a317dfc NaN-safe masking in vmapped_deflections_from).
The traced grids and images for the tutorial's singular-isothermal tracer are
now finite, so the plotters derive finite axis limits.

Tests

New file test_autolens/lens/plot/test_tracer_plots_nan_axis.py, reproducing the
tutorial-3 four-galaxy, two-plane tracer (main lens with singular isothermal +
external shear and a satellite at z=0.5, two sources at z=1.0, Planck15) on a
grid whose pixels land on the singular mass centres:

  • test__traced_grids_and_image_are_finite_at_singular_mass_centres — producer
    guard: deflections at the singular mass centres must stay finite, otherwise the
    plotters would derive non-finite axis limits and crash (the original failure).
  • test__subplot_tracer__singular_mass_centres__does_not_raise
  • test__subplot_galaxies_images__singular_mass_centres__does_not_raise

8 passed locally (3 new + 5 pre-existing in test_tracer_plots.py).

API Changes

None — test-only.

🤖 Generated with Claude Code

Adds test_autolens/lens/plot/test_tracer_plots_nan_axis.py reproducing the
HowToLens chapter-1 tutorial_3_more_ray_tracing four-galaxy two-plane tracer on
a grid whose pixels coincide with the singular isothermal mass centres.

The original crash (ValueError: Axis limits cannot be NaN or Inf during
plotting) was already fixed producer-side: mass-profile deflections now handle
r=0, so the traced grids and images stay finite and the tracer plotters receive
finite axis-limit extents. These tests lock that in:

- traced grids (both planes) and the image are finite at the singular centres
- subplot_tracer and subplot_galaxies_images render without raising

Test-only; no library code changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 29, 2026
@Jammy2211 Jammy2211 merged commit 345a737 into main May 29, 2026
6 checks passed
@Jammy2211 Jammy2211 deleted the feature/howtolens-tutorial3-nan-axis-test branch May 29, 2026 08:33
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