Skip to content

refactor: top-level accessor/ and alignment/ packages - #40

Merged
mpvginde merged 1 commit into
mlwp-tools:refactor/alignmentfrom
leifdenby:refactor/accessor-alignment-layout
Oct 27, 2026
Merged

mpvginde merged 1 commit into
mlwp-tools:refactor/alignmentfrom
leifdenby:refactor/accessor-alignment-layout

Conversation

@leifdenby

@leifdenby leifdenby commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Addresses bullet 4 of my notes on #30: "high-level modules will be accessor, alignment and pipeline".

Changes

  • accessors/ → accessor/ (only mx.py, the xr.Dataset.mx accessor)
  • align/ → alignment/ (time, space, nans)
  • interpolations/ → alignment/interpolations/, since it's only used by space alignment. alignment/__init__.py imports it so the interpolators still register on import mxalign.
  • Relative imports updated (mx.py, interpolations/base.py, alignment/space.py, runner.py) and tests updated to the new paths, including the mxalign.alignment.time logger name.
  • mxalign/__init__.py re-exports the same public functions (interpolate, align_time, align_space, registries). __all__ now lists accessor / alignment instead of accessors / interpolations.

pipeline (cli/runner/verification/transformations) follows in the next PR.

All 93 tests pass.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Although the refactor itself is correct and complete, it builds on and includes the unmerged #39 and targets the refactor/alignment branch, so it should not be merged until its prerequisite lands.

No open issues 🎉

What changed in this PR

This PR renames the top-level packages to the target layout from the author's refactor notes on #30: accessors/ → accessor/ (holding only the xr.Dataset.mx accessor), align/ → alignment/, and nests interpolations/ under alignment/interpolations/ since it is only used by space alignment. It is a pure move/rename with no behavioral change, building on #39, and keeps the public API in mxalign/__init__.py stable.

Changes:

  • Renamed/relocated the three packages and updated all relative imports to the new dot-levels (e.g. interpolations/base.py now uses ...utils.traits, accessor/mx.py imports ..alignment).
  • alignment/__init__.py imports interpolations so interpolators still register on import mxalign; mxalign/__init__.py re-exports the same public functions and updates __all__ to accessor/alignment.
  • Updated tests to the new import paths and the mxalign.alignment.time logger name.
File Description
src/​mxalign/​__init__.py Updates imports/__all__ to new accessor/alignment paths; public API unchanged
src/​mxalign/​accessor/​__init__.py New package init that imports mx to register the accessor
src/​mxalign/​accessor/​mx.py Imports time/space from ..alignment instead of local package
src/​mxalign/​alignment/​__init__.py Adds interpolations to package imports and __all__
src/​mxalign/​alignment/​time.py Hosts global + pairwise time ops; adds numpy/pandas imports, drops old accessors import
src/​mxalign/​alignment/​space.py Hosts align_space + pairwise grid ops; lazy-imports .interpolations.registry
src/​mxalign/​alignment/​nans.py Relocated broadcast_nans
src/​mxalign/​alignment/​interpolations/​* Relocated interpolation modules/registry; base.py import fixed to ...utils.traits
src/​mxalign/​runner.py Imports align_time/broadcast_nans from .alignment
src/​mxalign/​accessors/​*, src/​mxalign/​align/​space.py Old modules removed
tests/​test_interpolations.py, tests/​test_align_time_global.py Updated import paths and logger name

Verification performed: old accessors/, align/, interpolations/ directories are fully removed; no code references the old module paths (the only matches are saved stack-trace text in examples/introduction.ipynb output cells, which are not executable and not part of this diff); every _time.*/_space.* function used by accessor/mx.py exists in the new modules; relative-import dot-levels are correct; and the __init__.py import ordering avoids circular imports (accessor is imported after alignment, and alignment modules don't import the accessor at module load). I found no issues to raise.

Review effort: Balanced

@leifdenby
leifdenby requested a review from mpvginde October 27, 2026 11:51
…r alignment

Top-level layout becomes `accessor` (the ds.mx accessor) and
`alignment` (time/space/nans alignment plus the interpolators it uses);
the pipeline package follows separately. Public re-exports from
mxalign/__init__.py are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mpvginde
mpvginde merged commit d6c909e into mlwp-tools:refactor/alignment Oct 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants