test: regression guard for HowToLens tutorial_3 NaN axis-limits crash#560
Merged
Merged
Conversation
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>
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
Regression test locking in the fix for the HowToLens chapter-1
tutorial_3_more_ray_tracingcrash:ValueError: Axis limits cannot be NaN or Inf during plotting.The crash no longer reproduces on
main— it was fixed producer-side (massprofile deflections now handle
r = 0; cf. autogalaxy398f7417"handle r=0 inNFWSph deflections" and
8a317dfcNaN-safe masking invmapped_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 thetutorial-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— producerguard: 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_raisetest__subplot_galaxies_images__singular_mass_centres__does_not_raise8 passed locally (3 new + 5 pre-existing in
test_tracer_plots.py).API Changes
None — test-only.
🤖 Generated with Claude Code