Skip to content

fix: drop stale astropy <=7.2.0 cap + stale cosmology docstrings #434

Description

@Jammy2211

Overview

astropy is capped at >=5.0,<=7.2.0 in PyAutoArray and PyAutoGalaxy, so a fresh pip install downgrades users to astropy 7.2.0 even though the dev stack runs 8.0.1 and passes. Since the cap was filed, the stack's dependency convention moved to floors-not-pins (PyAutoArray#433 / PyAutoLens#687); PyAutoFit and PyAutoNerves already declare astropy>=5.0 uncapped. Added scope: autogalaxy/cosmology/model.py was reimplemented natively (JAX-compatible, no astropy import) but two docstrings still claim to wrap astropy functions — corrected in the same pass.

Plan

  • Drop the astropy cap in PyAutoArray and PyAutoGalaxy pyproject.toml, leaving the floor astropy>=5.0 (matches the PyAutoFit / PyAutoNerves convention).
  • Fix the stale astropy claims in the cosmology docstrings; keep the accurate parity statements.
  • Verify a clean-venv resolve pulls astropy 8.x, run both library test suites, smoke an imaging fit that exercises FITS/WCS.
  • Ship library-first: PyAutoArray, then PyAutoGalaxy.
Detailed implementation plan

Affected Repositories

  • PyAutoArray (primary)
  • PyAutoGalaxy

Branch Survey

Repository Current Branch Dirty?
./PyAutoArray main clean
./PyAutoGalaxy main clean

Suggested branch: feature/astropy-cap-bump
Worktree root: ~/Code/PyAutoLabs-wt/astropy-cap-bump/ · Work Classification: Library
Parallel-claim note: PyAutoGalaxy is also claimed by active task yang24-sidm-gravothermal-profile; human approved parallel run 2026-08-06 (file overlap nil: pyproject + cosmology docstrings vs new dark-mass profile).
Sizing note: Brain scored 13/too-large with a 4-phase split — prose-driven artifact; actual scope is 2 repos / 3 files / no API change. Kept as one task.

Implementation Steps

  1. PyAutoArray/pyproject.toml line 32: "astropy>=5.0,<=7.2.0""astropy>=5.0".
  2. PyAutoGalaxy/pyproject.toml line 34: same edit (keep the two specifiers identical).
  3. autogalaxy/cosmology/model.py docstring fixes:
    • angular_diameter_distance_to_earth_in_kpc_from (~line 126) and angular_diameter_distance_between_redshifts_in_kpc_from (~line 142): remove "returns only the value of the astropy function it wraps" — state the native implementation returns a plain value in kpc.
    • critical_density (~lines 215-221): replace the conversational porting note with a direct statement: native xp (NumPy/JAX) implementation returning Msun/kpc^3, value-matching astropy.cosmology.FLRW.critical_density(z) after unit conversion.
    • KEEP accurate parity statements (lines ~42, 61, 102, 454, 517, 756) — they document a real compatibility contract.
  4. Tests: pytest test_autoarray/, pytest test_autogalaxy/ (docstring-only source change; suites must pass).
  5. Clean-venv verify (fresh venv, PYTHONPATH cleared): resolve pulls astropy 8.x, not 7.2.0.
  6. Smoke: one imaging-fit script loading FITS/WCS under astropy 8.0.1.

Key Files

  • PyAutoArray/pyproject.toml — dependency floor
  • PyAutoGalaxy/pyproject.toml — dependency floor
  • PyAutoGalaxy/autogalaxy/cosmology/model.py — stale docstrings

Original Prompt

Click to expand starting prompt

Bump astropy cap to allow 8.x (drop the stale <=7.2.0)

Type: maintenance
Target: PyAutoArray
Repos:

  • PyAutoArray
  • PyAutoGalaxy
    Difficulty: small
    Autonomy: supervised
    Priority: normal
    Status: formalised

Filed 2026-07-12 from a /hygiene deps audit.

Why

astropy is capped at >=5.0,<=7.2.0 in both PyAutoArray and
PyAutoGalaxy pyproject.toml. The cap is demonstrably too tight: the
development venv already runs astropy 8.0.1 with the full stack passing, and
PyPI latest is 8.0.1. A fresh pip install today would downgrade astropy to
7.2.0 because of the cap. This is the clearest stale cap in the audit — the
installed environment is the proof it works.

Scope

  • Raise the astropy cap in PyAutoArray/pyproject.toml and
    PyAutoGalaxy/pyproject.toml. Convention update (2026-08-06): since this was
    filed, the stack moved to floors, not pins (PyAutoArray#433 /
    PyAutoLens#687 dep-floors work; PyAutoFit and PyAutoNerves already declare
    astropy>=5.0 uncapped) — so drop the cap entirely: astropy>=5.0.
  • Keep the two repos' astropy specifiers consistent (they match today; the
    audit found no cross-repo conflict — don't introduce one).
  • No source changes expected; astropy 8 already imports and runs in the venv.
  • Added scope (human request 2026-08-06): stale astropy docstrings in
    autogalaxy/cosmology/model.py.
    The cosmology was reimplemented natively
    (JAX-compatible) and no longer imports astropy, but two docstrings still say
    "returns only the value of the astropy function it wraps" (lines ~126, ~142)
    and critical_density carries a conversational porting note ("Astropy
    returns g/cm^3, but in AutoLens you were immediately converting…",
    lines ~215-221). Rewrite these to state the native implementation and units
    directly. KEEP the accurate parity statements ("matches
    astropy.cosmology.arcsec_per_kpc_proper", "values match astropy Planck15",
    interface "follows the astropy FlatLambdaCDM class") — they document a real
    compatibility contract.

Verify

  • Library-first ship: PyAutoArray then PyAutoGalaxy (Galaxy inherits Array).
  • Smoke: an imaging fit that touches astropy (WCS / units) still runs.
  • Confirm a clean-venv resolve pulls astropy 8.x, not 7.2.0.

Out of scope (recorded, not this task)

Other stale caps from the same audit — route separately if wanted: scipy
<=1.17.1→1.18.0, scikit-learn <=1.8.0→1.9.0, xxhash <=3.4.1→3.8.1
(Tier 1); networkx ==3.1→3.6.1, psutil ==6.1.0→7.2.2, corner
==2.2.2→2.3.0, nufftax <0.5.0→0.6.1 (Tier 2). Tier-4 sampler pins
(dynesty/nautilus/zeus/getdist/colossus) intentionally left alone.

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