Skip to content

Track sectionate 0.4.0rc2: drop the removed layer/interface kwargs - #31

Merged
hdrake merged 2 commits into
topology-overhaulfrom
sectionate-rc2-compat
Aug 10, 2026
Merged

Track sectionate 0.4.0rc2: drop the removed layer/interface kwargs#31
hdrake merged 2 commits into
topology-overhaulfrom
sectionate-rc2-compat

Conversation

@hdrake

@hdrake hdrake commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Makes topology-overhaul work against the pre-released sectionate >= 0.4.0rc2.

What changed and why

sectionate 0.4.0rc2 removed the layer and interface keyword arguments from convergent_transport:

rc1: (grid, i_c, j_c, f_c, utr, vtr, layer, interface, outname, sect_coord, geometry, positive_in, cell_widths)
rc2: (grid, i_c, j_c, f_c, utr, vtr,                  outname, sect_coord, geometry, positive_in, cell_widths)

Upstream that is hdrake/sectionate#7, "Take the vertical coordinates from the data and the grid; drop layer/interface". The reasoning there: the layer (cell-center) coordinate is a dimension of utr/vtr themselves, so it already rides along into the section — naming it only re-attached a coordinate that was on the output either way. The interface coordinate genuinely cannot ride along (it is one point longer, so it is a dimension of nothing on the section), but the grid knows it without being told: whichever axis registers the transports' layer dimension at its "center" position names the interface at "outer"/"inner"/"left"/"right". So neither parameter is needed, both were removed rather than re-validated, and passing either now raises TypeError.

regionate's library code never passed them — only the real-grid tests and the example notebooks did. This PR bumps the floor and updates those call sites.

File Change
pyproject.toml sectionate >= 0.4.0rc1>= 0.4.0rc2
regionate/tests/test_real_grids.py 3 call sites lose layer=/interface=
examples/1..5*.ipynb the same 8 notebook call sites, re-executed
.github/workflows/ci.yml drop the dead git-ref sectionate install + its stale TODO

No assertion, tolerance, or substantive check was changed. The tests still verify exactly what they did before (the discrete divergence theorem, the Arctic-fold single-region trace, the ECCO hard-topology closures).

The one behavioral difference, and why it is inert

Two of the three test call sites passed layer=None, which was already a no-op. The third passed layer="z_l", interface="z_i" on a grid that declares only X and Y axes. Under rc2 I confirmed empirically on that exact grid:

  • z_l still arrives on the section output, with the right values ([3000]), because it is a dimension of T_adx/T_ady. The test's .sum("z_l") is unaffected and the summed value is unchanged.
  • z_i is no longer attached, because no axis of that grid registers z_l at "center" for _interface_coords to read the interface name off.

Nothing in regionate or its examples reads z_i — it is only ever created, in the two data-setup blocks. So the loss has no consumer and no number moved. If we later want z_i to keep riding along, the upstream-intended fix is to declare the vertical axis on the xgcm.Grid ("Z": {"center": "z_l", "outer": "z_i"}) rather than to name it at the call site; I did not do that here because it is a separate change with no current consumer. Flagging it as a judgement call worth a second opinion.

The pre-release floor resolves without --pre

The CI comment asserts this, so I checked it rather than assuming. A clean venv (pip 26.2.1), pip install --dry-run -e ., no --pre:

Would install ... sectionate-0.4.0rc2 ... xgcm-0.10.1 ...

A pre-release floor permits pre-releases of that package, so neither --pre nor a git ref is needed in CI.

Test counts actually measured

Clean venv, Python 3.12.7, sectionate==0.4.0rc2, xgcm==0.10.1, xarray 2026.7.0, regionmask 0.13.0:

Suite Before (at 5e4a17b, on rc2) After
pytest -q 48 passed, 10 skipped 48 passed, 10 skipped
REGIONATE_REALDATA_TESTS=1 pytest -q 50 passed, 8 failed 58 passed

Every one of the 8 failures was TypeError: convergent_transport() got an unexpected keyword argument 'layer'. Both suites were re-confirmed on a second clean venv at Python 3.13.9 with the same pins: 48 passed / 10 skipped and 58 passed.

For reference, the same commit on sectionate==0.4.0rc1 gave 48/10 and 58 passed — i.e. rc1 was already green, and this PR restores that on rc2.

Notebooks: re-executed

Yes — re-executed, in a clean venv pinned to the authoritative versions (sectionate==0.4.0rc2, xgcm==0.10.1), on Python 3.13.9 with matplotlib==3.10.3 and cartopy==0.25.0 chosen to match the toolchain the committed outputs were produced with. All five ran end to end with no errors.

I diffed every human-readable output (stdout streams and text/plain results) cell by cell, before vs after. Every substantive line is byte-identical — including Check whether the discrete Divergence Theorem holds: [[ True]] (nb 1) and divergence-theorem residual = 0.00e+00 (nb 5). Dropping the kwargs moved no number anywhere in the examples.

Exactly two textual lines differ, both machine-specific paths inside warnings, neither related to this change:

  1. 3_Arctic_heat_CM4p25.ipynb — the xgcm experimental north-fold UserWarning prints the emitting file's absolute path. It changes from your …/envs/regionate-pr22/… to my clean venv's path under /private/tmp/…/scratchpad/nb313/…. You will probably want to regenerate this one cell locally so the docs don't carry a scratch path; I left the genuine output rather than hand-editing it.
  2. 4_bounded_by_named_sections.ipynb — a tight_layout warning quoting the ipykernel_<pid> temp path, which changes on any re-execution on any machine.

The plot images also churn: PNG payloads shift slightly (different font/DPI metrics on this machine) even with matplotlib pinned to the same 3.10.3. That is unavoidable re-execution noise, not a change in what is plotted.

What I chose not to do

  • No new test. Per CLAUDE.md norm 4 I considered adding one, but this change touches only test call sites, notebook call sites, and dependency metadata — there is no new library behavior to cover, and the real-data suite going 50/8-failed → 58-passed on rc2 is the test. Inventing a test that asserts convergent_transport no longer accepts layer= would be testing sectionate's API from the wrong repo; upstream already covers it (TypeError for both removed keywords).
  • Did not declare a Z axis on the fold test's grid or on examples/load_example_model_grid.py's construct_grid, which would restore the z_i coordinate on section output. See above — no consumer, and it is a separate decision.
  • Did not touch docs/requirements.txt; it had already dropped its git-ref line.

Uncertainty a reviewer should resolve

  • Whether the scratch-venv path now embedded in 3_Arctic_heat_CM4p25.ipynb's warning output is acceptable, or should be regenerated locally.
  • Whether losing the z_i coordinate on section output is fine (I believe it is — nothing reads it) or whether the grids should declare their vertical axis.
  • CI itself is unverified from here: the workflow only triggers on main, so this PR into topology-overhaul will not run it. My evidence for the CI edit is the local dry-run resolution above, not a green run.

🤖 Generated with Claude Code

sectionate 0.4.0rc2 removes the `layer` and `interface` keyword arguments from
`convergent_transport` (hdrake/sectionate#7, "Take the vertical coordinates from
the data and the grid, not the caller"). The layer coordinate is a dimension of
`utr`/`vtr`, so it already rides along into the section; the interface coordinate
cannot, but the grid knows it -- whichever axis registers the layer dimension at
its "center" position names the interface. Neither needs a caller to name it, so
both parameters are gone and passing either now raises TypeError.

regionate's library code never passed them. Only the real-grid tests and the
example notebooks did, so this bumps the floor and updates those call sites:

- pyproject.toml: `sectionate >= 0.4.0rc1` -> `>= 0.4.0rc2`. A pre-release floor
  lets pip install pre-releases of that package, so a bare `pip install -e .`
  with no `--pre` resolves sectionate-0.4.0rc2 (verified by dry run).
- regionate/tests/test_real_grids.py: 3 call sites lose `layer=`/`interface=`.
  Two passed `layer=None`, which was already a no-op. The third passed
  layer="z_l", interface="z_i" on a grid declaring only X and Y axes; z_l still
  arrives from T_adx/T_ady (the test's `.sum("z_l")` is unaffected) while z_i is
  no longer attached to the section output, since no axis of that grid registers
  z_l at "center". Nothing reads z_i, and no assertion or tolerance changed.
- examples/1..5: the same 8 notebook call sites, re-executed.
- .github/workflows/ci.yml: drop the `sectionate @ git+...@topology-driven-neighbors`
  install. It was dead weight -- the git ref builds from a shallow clone and
  self-reports 0.1.dev251, and the following `pip install -e .` replaced it with
  the PyPI pre-release anyway. Its TODO comment, still citing a `>= 0.3.3` floor,
  goes with it.

Measured with sectionate 0.4.0rc2 + xgcm 0.10.1 in a clean venv, before -> after:
default suite 48 passed / 10 skipped -> unchanged; REGIONATE_REALDATA_TESTS=1
50 passed / 8 failed (all `TypeError: convergent_transport() got an unexpected
keyword argument 'layer'`) -> 58 passed. Confirmed on Python 3.12 and 3.13.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Removed comments regarding package dependencies and installation details.

@hdrake hdrake left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Looks great!

@hdrake
hdrake merged commit b8baa1d into topology-overhaul Aug 10, 2026
1 check 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.

1 participant