Skip to content

Broadcast vertices-to-bounds conversion over extra dimensions - #682

Open
nawaaaaaAaar wants to merge 2 commits into
xarray-contrib:mainfrom
nawaaaaaAaar:fix/vertices-broadcast-dimensions-163
Open

nawaaaaaAaar wants to merge 2 commits into
xarray-contrib:mainfrom
nawaaaaaAaar:fix/vertices-broadcast-dimensions-163

Conversation

@nawaaaaaAaar

@nawaaaaaAaar nawaaaaaAaar commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #163.

Add an optional core_dims argument to vertices_to_bounds so one or two vertex dimensions can be converted while extra dimensions are broadcast over. The implementation follows the apply_ufunc and ellipsis-indexing approach suggested in the issue. The existing call signature and one-/two-dimensional defaults remain supported.

Example:

vertices_to_bounds(
    lev_vertices, out_dims=["bounds", "test"], core_dims=["test"]
)

Reproduction and verification

The issue's four-dimensional profile example raises ValueError on unchanged upstream ee13cb860717299ca8f66d35461e5e50910f3d47. All five initial new broadcasting regression cases fail before the production change.

  • Full cf-xarray suite: 295 passed, 14 skipped, Python 3.12, xarray 2026.9.0.
  • Helper suite with xarray 2024.7.0 / NumPy 1.26.4: 10 passed.
  • Covers one/two core dimensions, non-trailing input dimensions, Dask laziness and broadcast chunks, broadcast coordinates, same-name resized dimensions, datetime dtype, and invalid dimensions.
  • Ruff lint/format checks and git diff --check: passed.
  • Mypy: no issues in 28 source files.

Dask core dimensions must each occupy a single chunk; broadcast dimensions retain their chunking. This is documented on the new parameter.

Hosted checks

The documentation build and pre-commit.ci have passed. Some test/type matrix jobs are still pending. Codecov's aggregate patch gate is currently failing at 76.47%, while its unittests flag reports 100% patch coverage; its report also warns that the comparison is 132 commits behind main. This remains an unresolved hosted gate. No coverage threshold or workflow configuration has been weakened to bypass it.

AI-assisted implementation and testing, with tests executed locally.

Copilot AI balanced review requested due to automatic review settings October 22, 2026 14:38

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.47059% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.98%. Comparing base (a9cebee) to head (807839c).
⚠️ Report is 132 commits behind head on main.

Files with missing lines Patch % Lines
cf_xarray/helpers.py 76.47% 5 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #682      +/-   ##
==========================================
+ Coverage   85.78%   86.98%   +1.19%     
==========================================
  Files          13       16       +3     
  Lines        2364     3373    +1009     
  Branches      183      316     +133     
==========================================
+ Hits         2028     2934     +906     
- Misses        303      390      +87     
- Partials       33       49      +16     
Flag Coverage Δ
mypy 46.01% <52.94%> (+7.48%) ⬆️
unittests 92.91% <100.00%> (-1.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dcherian
dcherian added this pull request to the merge queue Oct 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 23, 2026

This branch has not been deployed

No deployments
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.

Convert vertices to bounds for nD arrays

2 participants