Skip to content

fix: accept uint8 dtype aliases in Zarr v2 - #4381

Open
guhou-hvi wants to merge 2 commits into
zarr-developers:mainfrom
guhou-hvi:fix/uint8-dtype-aliases
Open

guhou-hvi wants to merge 2 commits into
zarr-developers:mainfrom
guhou-hvi:fix/uint8-dtype-aliases

Conversation

@guhou-hvi

Copy link
Copy Markdown

Summary

Addresses #3622.

A single-byte element has no internal byte ordering, so <u1, >u1 and
|u1 can describe the same uint8 data. Currently only |u1 is registered
as a UInt8 v2 name: the stored bytes are valid, but metadata parsing rejects
the two aliases and prevents the array from opening.

This accepts both aliases while keeping |u1 as the serialized name.

For reviewers

The implementation extends only the accepted UInt8 v2 names. <u1 and >u1
are accepted on input, while serialization remains |u1. Tests cover dtype
and registry parsing, reading local arrays containing [0, 128, 255],
canonical serialization, unchanged on-disk metadata after read-only access,
and rejection of invalid names and object codecs. Other dtypes and v3 are unchanged.

Local validation run by Codex on Windows with Python 3.12.2:

  • Selected dtype, registry, v2 metadata and array modules: 2978 passed, 758 skipped.
  • Ruff, formatting, spelling, docstring checks and changelog draft build passed.
  • Native Windows mypy reports two existing unused-ignore errors in
    tests/test_store/test_local.py, reproduced on main in the same environment.
    mypy --platform linux passes for 196 files; this is type analysis, not a Linux runtime test.

Codex implemented the code, tests and changelog, ran the local checks, and
translated and polished my explanation, and prepared the validation notes. A separate Codex agent performed a static review.
I have reviewed and understand the changes.

Author attestation

  • I am a human, these are my changes, and I have reviewed and understood every change and can explain why each is correct.

TODO

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions — no new API
  • New/modified features documented in docs/user-guide/*.md — bug fix; changelog added
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@codecov

codecov Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.22%. Comparing base (ae41d6e) to head (a2787b6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4381   +/-   ##
=======================================
  Coverage   94.22%   94.22%           
=======================================
  Files          92       92           
  Lines       12942    12942           
=======================================
  Hits        12195    12195           
  Misses        747      747           
Files with missing lines Coverage Δ
src/zarr/core/dtype/npy/int.py 99.38% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants