Skip to content

Reject whitespace in compressed MultiIndex level names - #677

Closed
nawaaaaaAaar wants to merge 1 commit into
xarray-contrib:mainfrom
nawaaaaaAaar:track15/compress-names
Closed

nawaaaaaAaar wants to merge 1 commit into
xarray-contrib:mainfrom
nawaaaaaAaar:track15/compress-names

Conversation

@nawaaaaaAaar

Copy link
Copy Markdown
Contributor

Fixes #570.

Reproduction and fix

A MultiIndex level such as "north south" is written into compress="north south lon", which is then parsed as three coordinate names. Reject whitespace-containing level names before producing an ambiguous encoded result and tell callers to rename the levels.

The validation is deliberately limited to levels of the selected MultiIndexes. Unrelated variable names containing spaces remain allowed.

Regression coverage

  • Space, tab and newline level names with both inferred and explicit index selection: all six cases failed before the fix.
  • Preserve the caller's dataset when rejecting names.
  • Unrelated spaced variable names still round-trip.
  • Full suite: 308 passed, 1 skipped on Python 3.12 / xarray 2026.9.0.
  • Coding suite: 21 passed on xarray 2024.7.0 (declared minimum).
  • Relevant pre-commit hooks and git diff --check.

AI-assisted implementation and tests. Documentation explains the restriction; no broad restriction on NetCDF variable names is introduced.

Copilot AI balanced review requested due to automatic review settings October 22, 2026 14:31
@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.09%. Comparing base (a9cebee) to head (d152432).
⚠️ Report is 132 commits behind head on main.

Files with missing lines Patch % Lines
cf_xarray/coding.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #677      +/-   ##
==========================================
+ Coverage   85.78%   87.09%   +1.30%     
==========================================
  Files          13       16       +3     
  Lines        2364     3355     +991     
  Branches      183      313     +130     
==========================================
+ Hits         2028     2922     +894     
- Misses        303      387      +84     
- Partials       33       46      +13     
Flag Coverage Δ
mypy 46.02% <0.00%> (+7.49%) ⬆️
unittests 92.84% <100.00%> (-1.15%) ⬇️

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.

@nawaaaaaAaar

Copy link
Copy Markdown
Contributor Author

Closing this overlapping PR in favor of #676, which was created by a concurrent contribution batch immediately before this submission. Please review #676 only; no competing implementation is intended.

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.

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.

assert no variable with spaces in name is used for compression by gathering

2 participants