Skip to content

fix: Align transformed mesh areas with adapt-image weights #605

Description

@Jammy2211

Overview

Align rectangular transformed geometry with the slim weight-map grid so adapt-image diagnostics work with over-sampling. Validate the compiled JAX return type against current code.

Plan

  • Reproduce the adapt-image geometry failure with unequal slim and oversampled sizes.
  • Align transformed areas with the edge calculation's grid convention.
  • Pin area/edge agreement and inspect adjacent properties.
  • Validate the existing JAX return guard and repair it only if still necessary.
Detailed implementation plan

Suggested branch: feature/mesh-geometry-transformed-areas

Classification: Both; PyAutoArray primary, autolens_workspace_test companion for JAX regression. Small localized repair despite router deriving large from the nonstandard Difficulty: easy header. Independent of the interpolation audit.

  1. In autoarray/inversion/mesh/mesh_geometry/rectangular.py, make areas_transformed pass self.data_grid.array rather than self.data_grid.over_sampled to adaptive_rectangular_areas_from, consistent with edges_transformed and slim mesh_weight_map.
  2. Extend test_autoarray/inversion/pixelization/mesh_geometry/test_rectangular.py with an actual RectangularBilinearAdaptImage mapper using sub-size > 1 and a nonuniform slim weight map. Call both properties and compare flattened areas to the outer product of positive edge spacings in correct row order. Include finite/nonnegative values and a sub-size 1 control. Confirm the new test reproduces IndexError on origin/main.
  3. Inspect adjacent geometry properties and areas_for_magnification for the same mismatch; fix only directly related occurrences. Do not broaden into interpolation algorithms or unrelated nonsquare geometry.
  4. The current edges_transformed already returns adaptive_rectangular_transformed_grid_from directly; inspect that helper and decorators before changing its return type. If raw JAX return is already supported, retain it. Otherwise use the documented NumPy-wrapper/JAX-raw guard and preserve NumPy API.
  5. Add a focused compiled JAX geometry check in autolens_workspace_test/scripts/misc/jax_assertions/, pinning edges/areas type, shape and parity with NumPy. Run the relevant existing rectangular likelihood jit/vmap smoke as well.
  6. Run focused geometry tests, full test_autoarray, new JAX coverage and applicable workspace smoke. Ship library then linked workspace PR. Report any additional diagnostic defects separately.

Worktree root: /home/jammy/Code/PyAutoLabs/.worktrees/autoarray-bundle-1, created once using Brain's worktree helper with PYAUTO_WT_ROOT inside this workspace. Shared repo worktrees: PyAutoArray, PyAutoGalaxy, autolens_workspace_test. Each member starts from origin/main on its own branch; execute and ship sequentially before switching the shared PyAutoArray worktree. One primary PyAutoArray issue and registry entry per member, linked companion PRs per repository as explicitly authorized. No merges.

Branch survey: PyAutoArray, PyAutoGalaxy and autolens_workspace_test canonical checkouts are clean on main. No target repo claims in active.md. Heart reports an unregistered sparse-operator-oversampling-cache/PyAutoArray worktree with 11 dirty files: preserve it and obtain overlap acknowledgement before setup. Recent PyAutoArray branches: main, feature/sparse-operator-oversampling-cache, chore/session-start-hook-regen, feature/delaunay-area-magnification-audit, claude/autonerves-floor-regime-stamp. Recent PyAutoGalaxy branches: main, chore/session-start-hook-regen. Recent autolens_workspace_test branches: main, feature/point-audits-wheel-provenance, feature/point-solver-image-accuracy, feature/point-solver-duplicate-policy, chore/session-start-hook-regen.

Execution: one native Sol delegate per member, sequential within shared repositories. Parent owns judgment and lifecycle. Pass the approved issue plan, branch, exact starting commit, worktree, permitted files, validation requirements; stop and return exact failure evidence rather than weakening tests. Full logs stay in ignored scratch. Applicable full library suites and workspace smoke checks, authoritative Heart verdict, then ship separately. Report counts without inventing results; CI must check Python 3.12 and 3.13. No tests have yet run for this bundle.

Original Prompt

Click to expand starting prompt

MeshGeometryRectangular.areas_transformed raises IndexError for adapt-image meshes

Type: bug
Target: PyAutoArray
Repos:

  • PyAutoArray
    Difficulty: easy
    Autonomy: safe
    Priority: low
    Status: formalised
    Consequence: glance
    Witness: areas_transformed and edges_transformed on a RectangularBilinearAdaptImage mapper both return, the areas equal the outer product of the edge spacings (unit test), and under xp=jnp edges_transformed either returns the raw array or is documented NumPy-only.
    Review-minutes: 3
    Filed: 2026-09-17

Found during the independent sanity check of PyAutoArray#556 (issue #552;
record complete/2026/09/mixed-precision-inversion-gap.md).

MeshGeometryRectangular.areas_transformed
(autoarray/inversion/mesh/mesh_geometry/rectangular.py) raises IndexError
for a RectangularBilinearAdaptImage mesh: it hands
adaptive_rectangular_areas_from the over-sampled data grid
(data_grid.over_sampled, 5056 points on the 316-pixel
autogalaxy_workspace_test smoke data) together with the 316-long
mesh_weight_map, so the weighted rank-CDF transform indexes the weight map
out of range. The sibling edges_transformed uses data_grid.array (316
points) and works; the areas it implies are what
adaptive_rectangular_areas_from intends. The failure is identical before and
after #556, so it is not a regression of that fix — nothing in the fit path
calls areas_transformed (it is a diagnostic/plotting property), which is why
no smoke script or unit test caught it.

Ask: make areas_transformed use the same data_grid as edges_transformed
(or the same convention the interpolator uses for the weight map), add a unit
test that calls both properties on an adapt-image rectangular mapper and
checks the areas equal the outer product of the edge spacings, and check
whether MeshGeometryRectangular has other properties with the same
over-sampled-vs-slim mismatch. Related, found in the same check:
edges_transformed raises under the JAX backend because it returns a
Grid2DIrregular, which is not a valid JAX type — decide whether it should
return the raw array under xp=jnp (the if xp is np: guard pattern of
docs/agents/jax_and_decorators.md) or be documented NumPy-only.

Reproducer: build the mapper as in
autogalaxy_workspace_test/scripts/imaging/jax_likelihood/rectangular.py
(NumPy backend) and read fit.inversion.linear_obj_list[0].mesh_geometry.areas_transformed
(the exact attribute path is the mapper's mesh geometry object; confirm at
start).

Activity

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