Skip to content

refactor: alignment - #30

Open
mpvginde wants to merge 59 commits into
mainfrom
refactor/alignment
Open

mpvginde wants to merge 59 commits into
mainfrom
refactor/alignment

Conversation

@mpvginde

Copy link
Copy Markdown
Contributor

Reasonable refactor that does the following:

  • One single mx accessor for xr.Datasets
  • Fix interpolation-bug for the delaunay interpolation
  • Harmonize the output structure of the align-functions
  • Update the example notebooks
  • Add tests

Should come in after #27

@mpvginde mpvginde added this to the v0.2.0 milestone Jun 22, 2026
mpvginde and others added 16 commits October 26, 2026 17:54
Accept lead times as strings like "6h" (single, list or array) and raise
on unknown options, bare numbers and lead times missing from the forecast
instead of silently returning all-NaN output. Fixes the ambiguous
truth-value error for array input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Traits are read from attrs on every predicate call, so they no longer go
stale on the cached accessor and datasets without traits only fail when a
trait is needed. add_xy and unstack no longer reassign self._ds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A one-item dict raised KeyError and a one-item list was unwrapped; both
functions now return the container type they were given. Also removes the
local `transform` shadowing the function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Point outputs of both interpolators inherited the source's cartopy `crs`
and `grid_mapping` dict, which made to_netcdf fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Weights are cached at module level, keyed by a hash of the full source and
target coordinates, so interpolator instances share them and grids with the
same shape and corner coordinates no longer reuse each other's weights.
When grid_index is merged into one chunk, leading dims are re-chunked with
"auto" so blocks stay near dask's array.chunk-size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mpvginde
mpvginde marked this pull request as ready for review October 26, 2026 20:06
@mpvginde

mpvginde commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @leifdenby , I fixed some open questions and lose threads
The branch is a healthy state now for you to have a look at.

accessors/time.py and accessors/space.py held alignment operations
rather than accessor code. Move them into align/time.py and
align/space.py next to the multi-dataset align_time/align_space, and
have the mx accessor import them from there. No behaviour change.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
leifdenby and others added 5 commits October 27, 2026 15:17
…r alignment (#40)

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>
* Move cli, runner, verification and their helpers into pipeline/

The YAML-driven pipeline (cli, runner, verification, transformations
and the config/dates/save helpers it alone uses) now lives in
mxalign.pipeline. The console script points at mxalign.pipeline.cli:main.
Public re-exports from mxalign/__init__.py are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Update Runner import in advanced example notebook

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Move cli, runner, verification and their helpers into pipeline/

The YAML-driven pipeline (cli, runner, verification, transformations
and the config/dates/save helpers it alone uses) now lives in
mxalign.pipeline. The console script points at mxalign.pipeline.cli:main.
Public re-exports from mxalign/__init__.py are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Update Runner import in advanced example notebook

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Validate pipeline config against an explicit pydantic schema

Replace the untyped Config dict wrapper with pydantic models
(PipelineConfig and one model per section) loaded via load_config().
Unknown or missing keys now fail when the Runner is created instead of
deep inside a run, and the Runner reads typed attributes rather than
popping keys (which also stops align() mutating the config). Keys that
are forwarded to loaders, transformations, metrics and save methods
are kept as pass-through kwargs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Use a non-typo unknown key in config test to satisfy codespell

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Michiel Van Ginderachter <81358394+mpvginde@users.noreply.github.com>
…lint; add AGENTS.md (#44)

* Move cli, runner, verification and their helpers into pipeline/

The YAML-driven pipeline (cli, runner, verification, transformations
and the config/dates/save helpers it alone uses) now lives in
mxalign.pipeline. The console script points at mxalign.pipeline.cli:main.
Public re-exports from mxalign/__init__.py are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Update Runner import in advanced example notebook

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Validate pipeline config against an explicit pydantic schema

Replace the untyped Config dict wrapper with pydantic models
(PipelineConfig and one model per section) loaded via load_config().
Unknown or missing keys now fail when the Runner is created instead of
deep inside a run, and the Runner reads typed attributes rather than
popping keys (which also stops align() mutating the config). Keys that
are forwarded to loaders, transformations, metrics and save methods
are kept as pass-through kwargs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Use a non-typo unknown key in config test to satisfy codespell

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Annotate and document all functions; enforce with ruff and numpydoc; add AGENTS.md

Every module, class, function and method in src/, tests/ and the example
loader now has type annotations on all arguments and return values and a
numpy-style docstring (Parameters/Returns/Raises). This is enforced in
pre-commit (and therefore CI) by ruff's ANN and D rules (numpy convention)
and the numpydoc-validation hook. AGENTS.md describes the package layout,
development tools and coding conventions.

No behaviour changes: apart from docstrings, annotations and import
sorting, the only code edits are sorting mxalign.__all__ and dict literals
in tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Michiel Van Ginderachter <81358394+mpvginde@users.noreply.github.com>
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.

2 participants