Skip to content

Tracer accepts non-iterable galaxies; multi-plane allows z_lens > z_source #532

Description

@rhayes777

Title: Tracer accepts non-iterable galaxies; multi-plane allows z_lens > z_source

Repo: Jammy2211/PyAutoLens

Tag: @Jammy2211


Two small validation gaps in al.Tracer. Found while auditing
autolens == 2026.5.21.1.

B4. Tracer accepts a string (or anything) for galaxies

import autolens as al
t = al.Tracer(galaxies="not a list")
# silently constructed; explodes much later

The first usage (t.image_2d_from(grid=...)) does eventually fail, but with a
confusing downstream error rather than TypeError("galaxies must be an iterable of Galaxy") at construction.

Bonus. Multi-plane configurations with z_lens > z_source

l = al.Galaxy(redshift=1.0, mass=al.mp.IsothermalSph(einstein_radius=1.0))
s = al.Galaxy(redshift=0.5,
              bulge=al.lp.Sersic(intensity=1.0, effective_radius=0.1,
                                 sersic_index=2))
t = al.Tracer(galaxies=[l, s])
np.array(t.image_2d_from(grid=grid)).sum()
# 65.05 — finite, no warning

Also: redshift = -0.5 and redshift = 1e-12 are both accepted. This may be
deliberate (multi-plane lensing supports lots of geometries) but in practice
"lens behind source" tends to be a user mistake worth a warning.

Environment

  • autolens == 2026.5.21.1, Python 3.12.8.

Repros at work/edge_case_tests/03_tracer.py and
work/edge_case_tests/09_more_edges.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