Skip to content

fix: accept lists of byte values as fill values for byte dtypes - #4493

Open
barlowa124 wants to merge 3 commits into
zarr-developers:mainfrom
barlowa124:bytes-fill-array-4453
Open

barlowa124 wants to merge 3 commits into
zarr-developers:mainfrom
barlowa124:bytes-fill-array-4453

Conversation

@barlowa124

@barlowa124 barlowa124 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refs #4453, fourth checklist item. A fill_value on a byte data type
must be written as a base64 string today, though the Zarr V3 spec also
permits a list of byte values. from_json_scalar on
NullTerminatedBytes, RawBytes and VariableLengthBytes rejected
that form, so a spec-valid fill_value: [65] raised TypeError.

The new check_json_byte_list in npy/common.py matches a JSON list
of integers 0 through 255, booleans excluded. All three byte dtypes
accept the form and convert through bytes(...). Anything else falls
through to the existing TypeError, whose message now names both
accepted forms.

For reviewers

Open question: should a byte list longer than the fixed length be
rejected rather than truncated by np.bytes_/np.void? Silent
truncation is kept because the base64 path already behaves that way,
keeping the two forms consistent.

Author attestation

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

TODO

Done:

  • Add unit tests and/or doctests in docstrings
  • Changes documented as a new file in changes/

Outstanding:

  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.md
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

barlowa124 and others added 2 commits October 8, 2026 15:35
The Zarr V3 spec allows fill values for byte data types to be given
either as a base64-encoded string or as an array of byte values, but
from_json_scalar only accepted the string form. NullTerminatedBytes,
RawBytes, and VariableLengthBytes now accept a JSON list of integers
in [0, 255] and reject non-byte elements with a clear TypeError.

Refs zarr-developers#4453

Generated with Devin
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.70%. Comparing base (069fd20) to head (4d09a43).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4493   +/-   ##
=======================================
  Coverage   94.69%   94.70%           
=======================================
  Files          94       94           
  Lines       13606    13627   +21     
=======================================
+ Hits        12884    12905   +21     
  Misses        722      722           
Files with missing lines Coverage Δ
src/zarr/core/dtype/npy/bytes.py 99.51% <100.00%> (+0.01%) ⬆️
src/zarr/core/dtype/npy/common.py 99.20% <100.00%> (+0.01%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant