Skip to content

fix: keep fill value and attributes in from_array - #4288

Merged
d-v-b merged 1 commit into
zarr-developers:mainfrom
paraseba:fix-from-array-keep-fill-value-attributes
Aug 26, 2026
Merged

fix: keep fill value and attributes in from_array#4288
d-v-b merged 1 commit into
zarr-developers:mainfrom
paraseba:fix-from-array-keep-fill-value-attributes

Conversation

@paraseba

@paraseba paraseba commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

from_array discards both fill_value and attributes.

An explicit fill_value=None now means the dtype's default scalar (v3) or a null fill value (v2), consistent with create_array, and an empty attributes dict opts out of copying the source's attributes.

Fixes #4287

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.

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.19%. Comparing base (d44f9f9) to head (b7decb5).

Files with missing lines Patch % Lines
src/zarr/testing/stateful.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4288      +/-   ##
==========================================
+ Coverage   94.12%   94.19%   +0.06%     
==========================================
  Files          92       92              
  Lines       12831    12825       -6     
==========================================
+ Hits        12077    12080       +3     
+ Misses        754      745       -9     
Files with missing lines Coverage Δ
src/zarr/api/synchronous.py 92.95% <ø> (ø)
src/zarr/core/array.py 97.95% <100.00%> (+0.09%) ⬆️
src/zarr/testing/stateful.py 36.36% <0.00%> (+0.78%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paraseba
paraseba force-pushed the fix-from-array-keep-fill-value-attributes branch from fdb41f4 to 7b8b72e Compare August 26, 2026 04:25
`from_array` discards both `fill_value` and `attributes`.

An explicit `fill_value=None` now means the dtype's default scalar (v3) or a
null fill value (v2), consistent with `create_array`, and an empty
`attributes` dict opts out of copying the source's attributes.

Fixes zarr-developers#4287
@paraseba
paraseba force-pushed the fix-from-array-keep-fill-value-attributes branch from 95b0cf9 to b7decb5 Compare August 26, 2026 04:29
@d-v-b

d-v-b commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

thanks @paraseba, this looks good.

long term we will need to make breaking changes around our use of None as a sentinel, because some data types (like a JSON data type) would use None as a scalar value. But that's a future problem.

@d-v-b
d-v-b merged commit 7729d92 into zarr-developers:main Aug 26, 2026
37 checks passed
paraseba added a commit to xyf5432/icechunk that referenced this pull request Aug 26, 2026
These errors were found by the nightly upstream-dev job.

zarr >= 3.3's `add_array` recreates the drawn array in the store under
test without the sharding codec the model store got, so an
all-fill-value write elides a chunk object on one side only. Override it
with the fix from zarr-developers/zarr-python#4288 until that reaches a
release.

`check_file_invariants` required orphan tx logs to equal the
pruned-ancestor refs of every snapshot whose *file* is on disk. This is
no longer true now that we keep expired tx logs.
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.

from_array silently discards the source array's fill_value and attributes

2 participants