Repository navigation
Conversation
Sevans711
self-requested a review
October 15, 2026 23:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1818
Overview
Allow
open_dataset(existing_grid, data)andopen_mfdataset(existing_grid, paths)to reuse the same Grid, its topology and cached properties without reconstructing it or sending it to a file backend.The Grid's existing chunking and source-dimension mapping are preserved. Data chunks are mapped without mutating the caller's dictionary. The mapping boundary also preserves canonical dimensions when node/face counts coincide and avoids re-flattening already-standardized structured members.
Grid-construction options
use_dual=Trueand nonemptygrid_kwargsraise actionable errors for an existing Grid.chunk_gridapplies when constructing grids; callers can explicitly callGrid.chunkbeforehand. For unflattened structured data, use original spatial dimension names for chunking, or rechunk after flattening.Expected Usage
In-memory xarray Dataset members and multi-file data are covered as well.
Validation
python -m unittest test.core.test_grid_reuse: 15 tests passed.git diff --checkpassed.Linux, Python 3.12.14; xarray 2026.9.0, Dask 2026.8.0, NumPy 2.5.4. The full test-suite attempt was killed with exit 137 after 47 passing progress dots; it did not complete. The final relevant suite above passed. The complete upstream CI matrix and full ASV suite have not run locally.
Existing UxDataset close-callback behavior and mixed native/flattened structured representations are not refactored by this patch.
PR Checklist
General
Testing & Benchmarking
Documentation and Examples
AI Disclosure
AI Usage: OpenAI Codex assisted with investigation, implementation, synthetic tests, benchmarking, and independent code review.