feat: add galaxy_table CSV reader/writer for galaxy populations#393
Merged
Conversation
Closes #392. Adds autogalaxy/galaxy/galaxy_table.py providing a typed schema layer over autoconf.csvable for CSV files describing galaxy populations (centres + luminosities + optional redshifts). Wraps the generic CSV I/O in autoconf and returns a GalaxyTable dataclass with centres: Grid2DIrregular, luminosities: list[float], redshifts: list[float] | None. Mirrors the typed-CSV-helper precedent in autolens.point.dataset (which owns the equivalent layer for point-source datasets) -- schema lives next to the typed object it describes. Consumers are the autolens_workspace scaling_relation examples (issue #141); the queued autogalaxy_extra_galaxies_audit follow-up will use it from autogalaxy_workspace too. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 10, 2026
Collaborator
Author
|
Workspace PR: PyAutoLabs/autolens_workspace#143 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a typed CSV reader/writer for galaxy populations --
GalaxyTabledataclass plusgalaxy_table_from_csv/galaxy_table_to_csv. Schema columns arey, x, luminosity, redshift?. Wrapsautoconf.csvablefor the underlying I/O; partial-redshift handling mirrors the convention used byautolens.point.dataset.Closes #392.
API Changes
Purely additive. Three new public symbols on
autogalaxy:ag.GalaxyTable-- dataclass withcentres,luminosities,redshiftsfieldsag.galaxy_table_from_csv(file_path) -> GalaxyTableag.galaxy_table_to_csv(centres, luminosities, file_path, redshifts=None) -> NoneNo removals, no renames, no signature changes. See full details below.
Test Plan
pytest test_autogalaxy/galaxy/test_galaxy_table.py-- 10 tests covering round-trip with/without redshift, missing redshift column, partial-redshift rejection, extra columns ignored, row order preserved, empty/header-only CSV, mismatched-length writer rejection.import autogalaxy as ag; ag.galaxy_table_from_csvresolves via the namespace export.Full API Changes (for automation & release notes)
Added
autogalaxy.galaxy.galaxy_table.GalaxyTable-- dataclass:centres: Grid2DIrregular, luminosities: List[float], redshifts: Optional[List[float]] = Noneautogalaxy.galaxy.galaxy_table.galaxy_table_from_csv(file_path: Union[str, Path]) -> GalaxyTableautogalaxy.galaxy.galaxy_table.galaxy_table_to_csv(centres: Sequence[Tuple[float, float]], luminosities: Sequence[float], file_path: Union[str, Path], redshifts: Optional[Sequence[float]] = None) -> NoneAll three are re-exported at the
autogalaxynamespace top-level:ag.GalaxyTable,ag.galaxy_table_from_csv,ag.galaxy_table_to_csv.Removed
None.
Renamed
None.
Changed Signature
None.
Changed Behaviour
None.
Migration
No migration needed -- purely additive.
🤖 Generated with Claude Code