Skip to content

refactor(zarr): clean up how the Zarr backend consumes the encoding dict - #11479

Open
d-v-b wants to merge 1 commit into
pydata:mainfrom
d-v-b:claude/zarr-encoding-refactor
Open

refactor(zarr): clean up how the Zarr backend consumes the encoding dict#11479
d-v-b wants to merge 1 commit into
pydata:mainfrom
d-v-b:claude/zarr-encoding-refactor

Conversation

@d-v-b

@d-v-b d-v-b commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

This PR consolidates logic for the encoding dict when working with Zarr arrays. New module-level constants are defined for the keys xarray cares about, a new function is added for validating the encoding dict, and the v2 / v3 differences re: dimension names are pushed down into a utility function.

There are no behavioral changes.

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: {e.g., Claude, Codex, GitHub Copilot, ChatGPT, etc.}

This work was done with claude. See the AI-generated source PR here: d-v-b#1

@github-actions github-actions Bot added topic-backends topic-zarr Related to zarr storage library io labels Jul 27, 2026
… path

Define the encoding keys the Zarr backend accepts as module-level constants
(ZARR_V2_ENCODING_KEYS, ZARR_V3_ENCODING_KEYS, ZARR_READ_ONLY_ENCODING_KEYS)
and extract a pure _validate_zarr_variable_encoding helper from
extract_zarr_variable_encoding.

_create_new_array now assembles zarr create() arguments in its own dict
instead of mutating the variable's encoding, takes the dimension names
explicitly, and records them in one place for both zarr formats (native
dimension_names metadata for format 3, the hidden _ARRAY_DIMENSIONS
attribute for format 2). Remove unreachable "order" handling from array
creation, and correct the formatting of the conflicting-write_empty_chunks
error message.

Behavior is otherwise unchanged; tests are split one case per function and
new tests pin the constants and the conflict error.

Assisted-by: ClaudeCode:claude-fable-5
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

io topic-backends topic-zarr Related to zarr storage library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant