Skip to content

Preserve StringDType in Zarr v3 round trips#11474

Open
stanbot8 wants to merge 1 commit into
pydata:mainfrom
stanbot8:fix/11466-stringdtype-zarr
Open

Preserve StringDType in Zarr v3 round trips#11474
stanbot8 wants to merge 1 commit into
pydata:mainfrom
stanbot8:fix/11466-stringdtype-zarr

Conversation

@stanbot8

@stanbot8 stanbot8 commented Jul 25, 2026

Copy link
Copy Markdown

Summary

Zarr format 3 round trips change NumPy StringDType arrays to fixed-width Unicode arrays. Preserve NumPy StringDType for variables and coordinates in Zarr format 3 round trips. Closes #11466.

Design

The shared string encoder converts native StringDType arrays to fixed-width Unicode before the Zarr format 3 writer receives them. The Zarr format 3 path preserves the native stored dtype, and the shared decoder retains that dtype when the storage encoding matches it.

The implementation changes doc/whats-new.rst, xarray/backends/zarr.py, and xarray/coding/variables.py.

Tests

The baseline failed, and the candidate passed the same reproducer. The focused A/B reproducer passed on the candidate. 417 tests passed, 55 tests skipped, and 4 tests had expected failures. The repository quality checks passed in CI.

The tests are in xarray/tests/test_backends.py.

Commands
python -m pytest xarray/tests/test_coding.py xarray/tests/test_backends.py::test_roundtrip_stringdtype_zarr_v3 xarray/tests/test_backends.py::TestZarrDictStore -q
pre-commit run --files xarray/backends/zarr.py xarray/coding/variables.py xarray/tests/test_backends.py doc/whats-new.rst

Checklist

@welcome

welcome Bot commented Jul 25, 2026

Copy link
Copy Markdown

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient.
If you have questions, some answers may be found in our contributing guidelines.

@github-actions github-actions Bot added topic-backends topic-zarr Related to zarr storage library io labels Jul 25, 2026
@stanbot8
stanbot8 force-pushed the fix/11466-stringdtype-zarr branch from 9897f7d to db97531 Compare July 25, 2026 17:27
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.

StringDType does not roundtrip through zarr

1 participant