Motivation
The module layout grew organically and is hard to navigate: NumPy code is split across
pyAMICA.py + amica_*.py prefixed modules, and the PyTorch code carries amica_torch.py,
amica_torch_ng.py, amica_torch_v2.py. We want clean, topic-based names (newton, pdf,
data, ...) shared conceptually between backends, with PyTorch counterparts where needed, and no
redundant amica_/_torch/_v2 prefixes. Clean code is a first-class goal, not cosmetic.
This is intentionally separate from the parity work (epic #9 / PR #33) so renames don't muddy
the parity diff.
Proposed target structure
pyAMICA/
├── amica.py # public scikit-learn-style interface (unchanged import path)
├── version.py
├── numpy_impl/ # (or keep flat) legacy NumPy reference
│ ├── core.py # was pyAMICA.py (AMICA_NumPy)
│ ├── newton.py # was amica_newton.py
│ ├── pdf.py # was amica_pdf.py
│ ├── data.py # was amica_data.py
│ ├── load.py # was amica_load.py
│ ├── viz.py # was amica_viz.py
│ ├── utils.py # was amica_utils.py
│ └── cli.py # was amica_cli.py
└── torch_impl/
├── core.py # was amica_torch_ng.py (AMICATorchNG, the parity backend)
├── newton.py # was newton_optimizer.py
├── pdf.py # was adaptive_pdf.py
├── mixture.py # was mixture_models.py
├── optim.py # was optimizers.py
├── output.py # was fortran_output.py
└── utils.py # unchanged
(Exact package split -- flat vs numpy_impl/ -- to be decided in phase 1.)
Constraints
- Keep the public import surface stable:
from pyAMICA import AMICA, AMICA_NumPy, AMICATorchNG.
- No backward-compat shims / re-export stubs for old module paths (per project rules); update all
call sites, tests, CLI, and docs directly.
- Real-data tests stay green throughout; parity unchanged.
Suggested phasing (sub-issues to be created when this starts)
- Decide package layout + rename the PyTorch
torch_impl/ modules; update imports/tests/docs.
- Rename the NumPy modules (
amica_*.py -> topic names); update pyAMICA.py->core, CLI, tests.
- Docs/ADR pass; update AGENTS.md architecture map and Key Files.
Depends on / coordinate with
Not scheduled yet -- filed to capture intent; start after PR #33 (and ideally #32) land.
Motivation
The module layout grew organically and is hard to navigate: NumPy code is split across
pyAMICA.py+amica_*.pyprefixed modules, and the PyTorch code carriesamica_torch.py,amica_torch_ng.py,amica_torch_v2.py. We want clean, topic-based names (newton,pdf,data, ...) shared conceptually between backends, with PyTorch counterparts where needed, and noredundant
amica_/_torch/_v2prefixes. Clean code is a first-class goal, not cosmetic.This is intentionally separate from the parity work (epic #9 / PR #33) so renames don't muddy
the parity diff.
Proposed target structure
(Exact package split -- flat vs
numpy_impl/-- to be decided in phase 1.)Constraints
from pyAMICA import AMICA, AMICA_NumPy, AMICATorchNG.call sites, tests, CLI, and docs directly.
Suggested phasing (sub-issues to be created when this starts)
torch_impl/modules; update imports/tests/docs.amica_*.py-> topic names); updatepyAMICA.py->core, CLI, tests.Depends on / coordinate with
AMICATorchV2, retire the basicamica_torch.py, promotebackend="ng"):do that first so we don't rename files that are about to be deleted.
amica_torch.pysurvives the rename.Not scheduled yet -- filed to capture intent; start after PR #33 (and ideally #32) land.