Skip to content

Allow non-string names for indexed coordinates - #11876

Open
headtr1ck wants to merge 3 commits into
pydata:mainfrom
headtr1ck:nonstr-index-names
Open

headtr1ck wants to merge 3 commits into
pydata:mainfrom
headtr1ck:nonstr-index-names

Conversation

@headtr1ck

@headtr1ck headtr1ck commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Indexed coordinates can now have non-string names, like other variables:

  • Indexes.__init__ and Index.create_variables (also in NDPointIndex) copied mappings with dict(**mapping), which only accepts string keys, so e.g. DataArray(..., dims=(10,), coords={10: [...]}) raised TypeError: keywords must be strings. They now use dict(mapping). The ** form dates from Explicit indexes #5692 and Expose "Coordinates" as part of Xarray's public API #7368 and was only meant as a copy.
  • The five HTML repr tests for non-string names are merged into one test that covers dimensions, coordinates, indexes, data variables and attributes for Variable, DataArray, Dataset and DataTree.

Checklist

  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst

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: Claude Code

🤖 Generated with Claude Code

headtr1ck and others added 3 commits November 15, 2026 21:22
`Indexes.__init__` and `Index.create_variables` copied mappings with
`dict(**mapping)`, which only accepts string keys, so an indexed coordinate
named e.g. `10` or `("a", "b")` raised `TypeError: keywords must be strings`.

Also generalize the HTML repr tests for non-string names into one test
covering dimensions, coordinates, indexes, variables and attributes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@headtr1ck headtr1ck added the plan to merge Final call for comments label Nov 15, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant