Skip to content

feat: cluster plots honor the configured critical-curve engine #807

Closed

Description

@Jammy2211

Overview

Phase 3a subtask of the cluster-strong-lensing epic (PyAutoMind ledger draft/feature/autolens/source_cluster_arc.md). autolens/cluster/plot/cluster_plots.py draws per-source-plane critical curves and caustics through the multi-plane LensCalc. It always calls the marching-squares methods directly, ignoring general.critical_curves_method in the visualize config. Every other plot honours that setting through PyAutoGalaxy's autogalaxy.util.plot_utils._critical_curves_method(). This issue makes plot_critical_curves and plot_caustics honour it too, so cluster plots agree with the rest of the library.

Plan

  • In plot_critical_curves and plot_caustics, choose each source plane's curve routine from _critical_curves_method():

    • marching_squares is the default and keeps today's behaviour;
    • zero_contour uses LensCalc's existing *_via_zero_contour_from methods;
    • the selector's config and missing-dependency fallback apply unchanged.
  • Preserve LensCalc.from_tracer(use_multi_plane=True, plane_j=j), per-plane colours, labels, the radial option and the source-plane mapping.

  • Tests on a two-source-plane cluster fixture:

    • assert which routine each engine calls, for tangential and radial curves and caustics;
    • assert the per-plane geometry is distinct;
    • check that a configured zero_contour falls back when jax_zero_contour is unavailable.

    These tests check the plotting routing only. They do not claim JIT or gradient safety.

  • PyAutoLens only.

Tier: judge — merge mode: human /prm

Detailed implementation plan

Affected Repositories

  • PyAutoLens (only)

Branch Survey

Repository Current Branch Dirty?
PyAutoLens (origin/main b29ffcc) main clean

No active.md claim on PyAutoLens.

Suggested branch: feature/cluster-curves-engine-dispatch

Implementation Steps

  1. autolens/cluster/plot/cluster_plots.py:
    • Add a small helper that maps (method, kind ∈ {tangential, radial} × {critical curve, caustic}) to the LensCalc routine. For marching_squares that is tangential_critical_curve_list_from and the existing routines; for zero_contour it is tangential_critical_curve_list_via_zero_contour_from and its siblings (autogalaxy/operate/lens_calc.py ~1500–1700).
    • Read the method once per plot call via autogalaxy.util.plot_utils._critical_curves_method().
    • Mirror how autogalaxy/util/plot_utils.py (~470–540) and autolens/lens/plot/critical_curves.py call the zero-contour variants (their arguments: grid, initial points, etc.).
    • Keep _lens_calc_for_plane as is.
  2. Docstrings: describe the engine choice. Keep the marching-squares grid note.
  3. Tests in test_autolens/cluster/plot/ (or beside the existing cluster plot tests), on a two-source-plane cluster fixture:
    • monkeypatch the selector to each engine and spy on the LensCalc methods called, for tangential and radial curves and caustics, per plane;
    • assert the plane-1 and plane-2 geometries differ;
    • set the config to zero_contour while jax_zero_contour import fails, and assert the marching-squares fallback (the selector warns).
  4. Run the focused PyAutoLens tests and the full suite. Workspace cluster visualisation smoke, if available.

Key Files

  • autolens/cluster/plot/cluster_plots.py (_lens_calc_for_plane ~167, plot_critical_curves ~346, plot_caustics ~440)
  • PyAutoGalaxy autogalaxy/util/plot_utils.py:405 (_critical_curves_method) and ~470–540 (how other plots dispatch)
  • PyAutoGalaxy autogalaxy/operate/lens_calc.py ~1431–1720 (*_via_zero_contour_from)
  • autolens/lens/plot/critical_curves.py

Out of scope

Context-aware JIT dispatch, docstring fixes elsewhere, cluster-scale accuracy and performance, and the jax_zero_contour triage: these are the remaining phase-3 scope.

Original Prompt

Click to expand starting prompt

PyAutoMind draft/feature/autolens/cluster_curves_engine_dispatch.md (Epic: cluster-strong-lensing, Phase: 3a, Consequence: judge).

Make autolens/cluster/plot/cluster_plots.py select the existing configured critical-curve engine for each source plane in plot_critical_curves and plot_caustics. Preserve LensCalc.from_tracer(use_multi_plane=True, plane_j=j) and per-plane colours, labels, radial option and source-plane mapping. The default remains marching_squares; explicit zero_contour uses the existing LensCalc zero-contour methods. Use PyAutoGalaxy's existing private method selector so config and missing-dependency fallback agree with other plots. Keep changes in PyAutoLens only.

Verify both configured engines on a two-source-plane cluster fixture, including tangential and radial curves and caustics. Tests must assert method routing and distinct per-plane geometry, not merely saved image paths. Check the configured-zero-contour behavior when the dependency is unavailable. Run focused PyAutoLens tests and appropriate workspace cluster visualization smoke. Do not claim JIT or gradient safety from a plotting test.

Activity

  1. Jammy2211 commented on Oct 28, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    #808 merged 2026-10-28 as merge commit 1faa99a, labelled pending-release. Head a0666e7 was green on every leg (unittest 3.12, 3.13, nojax; docs-build).

    Cluster plot_critical_curves / plot_caustics now honour general.critical_curves_method through PyAutoGalaxy's shared selector:

    • marching_squares is the default and is unchanged;
    • zero_contour uses LensCalc *_via_zero_contour_from.

    Left for the remaining phase-3 scope: zero_contour seeds only from LensCalc's ±3" scan, so cluster-scale curves outside that box are not drawn.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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