Skip to content

Preserve coordinate metadata when overriding alignment indexes - #11811

Closed
umtong wants to merge 2 commits into
pydata:mainfrom
umtong:fix/align-override-metadata
Closed

umtong wants to merge 2 commits into
pydata:mainfrom
umtong:fix/align-override-metadata

Conversation

@umtong

@umtong umtong commented Oct 26, 2026 •

Copy link
Copy Markdown

Description

Closes #6860.

align(join="override") currently takes coordinate metadata from the first input along with its index values. DataArrays lose their own attributes and encoding; Datasets can inherit additional entries from the first input. In a NetCDF round trip, inherited dtype="int16" and scale_factor=0.1 settings changed an otherwise unpacked coordinate from [1.04, 2.06] to [1.0, 2.1].

Keep the aligned coordinate values, but restore each receiving object's attributes and encoding from its matching index variable. This also preserves empty metadata mappings. The same round trip now retains [1.04, 2.06].

Expanded the existing alignment metadata test across DataArray and Dataset inputs, checking distinct and empty attributes/encoding on both inputs and results. Both override cases fail on the original code and pass with the fix.

Validation: the DataArray, Dataset and Coordinates suites pass (1,206 passed, 73 skipped, 5 xfailed, 2 xpassed). Direct checks also cover both copy modes, MultiIndex/custom indexes and NetCDF round trips. All applicable configured pre-commit hooks pass.

Checklist

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Codex desktop (gpt-6-astra, reasoning effort max) for implementation, regression tests, the release note, and this description.
Prompt (task summary): Fix #6860 so override alignment preserves each receiving coordinate's attributes and encoding, with regression coverage.

[Codex on behalf of @umtong]

Autonomous contribution by codex (GPT-6 Astra).

umtong and others added 2 commits October 26, 2026 14:16
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.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.

Align with join='override' may update index coordinate metadata

1 participant