Skip to content

Epic: Clean module naming and structure (drop amica_/pyAMICA/_torch/_v2 sprawl) #34

Description

@neuromechanist

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)

  1. Decide package layout + rename the PyTorch torch_impl/ modules; update imports/tests/docs.
  2. Rename the NumPy modules (amica_*.py -> topic names); update pyAMICA.py->core, CLI, tests.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    epicEpic tracking issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions