Skip to content

PointSolver.solve crashes on single-image sources and on loose pixel_scale_precision #531

Description

@rhayes777

Title: PointSolver.solve crashes on single-image sources and on loose pixel_scale_precision

Repo: Jammy2211/PyAutoLens

Tag: @Jammy2211


Two crashes in PointSolver.solve that look like missing edge-case handling.
Both reproduce in a fresh venv with autolens == 2026.5.21.1, Python 3.12.

1. Source outside the caustic → single image → numpy.AxisError

import autolens as al

grid = al.Grid2D.uniform(shape_native=(80, 80), pixel_scales=0.05)
lens = al.Galaxy(
    redshift=0.5,
    mass=al.mp.Isothermal(centre=(0, 0), ell_comps=(0.1, 0), einstein_radius=1.0),
)
src_pos = (5.0, 5.0)                     # comfortably outside the caustic
src = al.Galaxy(redshift=1.0, point_0=al.ps.Point(centre=src_pos))
tracer = al.Tracer(galaxies=[lens, src])

solver = al.PointSolver.for_grid(grid=grid, pixel_scale_precision=0.001)
solver.solve(tracer=tracer, source_plane_coordinate=src_pos)
# numpy.exceptions.AxisError: axis 1 is out of bounds for array of dimension 1

A source far from the lens should produce a single image (approximately at the
source position). Instead the solver bails out with a NumPy axis error from
deep inside the iterative refinement.

2. Loose pixel_scale_precisionIndexError: list index out of range

src_pos = (0.05, 0.02)                   # well inside the caustic
src = al.Galaxy(redshift=1.0, point_0=al.ps.Point(centre=src_pos))
tracer = al.Tracer(galaxies=[lens, src])
solver = al.PointSolver.for_grid(grid=grid, pixel_scale_precision=0.1)
solver.solve(tracer=tracer, source_plane_coordinate=src_pos)
# IndexError: list index out of range

Same input as a working pixel_scale_precision=0.001 call (which returns
four images), only the precision was loosened. The solver doesn't gracefully
degrade — it indexes an empty candidate list.

Why it matters

Both inputs are realistic: surveys with many simulated lenses commonly have
configurations outside the caustic (especially during model exploration), and
"loose precision for a quick first pass" is exactly how one would script the
solver. A clear error ("source outside the caustic; only one image", or
"pixel_scale_precision is too large to resolve any image") would be
massively better than a raw AxisError / IndexError.

Environment

  • autolens / autogalaxy / autoarray / autofit / autoconf == 2026.5.21.1
  • Python 3.12.8, macOS arm64.

Full reproducer at work/edge_case_tests/08_point_solver.py in the audit
workspace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions