You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Negative zero (-0.0) is not distinguished from zero when reading back values from a Zarr array. This differs from the expected behaviour (and Zarr Python v2).
Steps to reproduce
# /// script# requires-python = ">=3.11"# dependencies = [# "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",# ]# ///## This script automatically imports the development branch of zarr to check for issuesimportnumpyasnpimportzarrprint(zarr.array(np.array([0.0, -0.0]))[:])
#zarr.print_debug_info()
thanks for this report, I did a quick check and this bug was present prior to the recent dtype changes, so that should help narrow the search down a bit.
thanks for this report, I did a quick check and this bug was present prior to the recent dtype changes, so that should help narrow the search down a bit.
Yes, sorry I forgot to say it is in 3.0.8 as well as main.
# /// script# requires-python = ">=3.11"# dependencies = [# "zarr==3.0.8",# ]# ///## This script automatically imports the development branch of zarr to check for issuesimportnumpyasnpimportzarrprint(zarr.array(np.array([0.0, -0.0]), fill_value=1)[:])
Adding a non-0 fill value preserves the signed 0 as expected. I also checked that the original test case doesn't write any chunks. So the error comes from zarr mistakenly identifying the chunk as empty during array creation, thenfailing to write it, which results in zarr using the fill value instead on indexing.
Activity
d-v-b commentedon Jun 18, 2025
thanks for this report, I did a quick check and this bug was present prior to the recent dtype changes, so that should help narrow the search down a bit.
tomwhite commentedon Jun 18, 2025
Yes, sorry I forgot to say it is in 3.0.8 as well as main.
d-v-b commentedon Jun 18, 2025
Adding a non-0 fill value preserves the signed 0 as expected. I also checked that the original test case doesn't write any chunks. So the error comes from zarr mistakenly identifying the chunk as empty during array creation, thenfailing to write it, which results in zarr using the fill value instead on indexing.
tomwhite commentedon Jun 18, 2025
Aha - which explains why it works on v2 - the default for
write_empty_chunksis True (it's False in v3). On v2 the following fails too:d-v-b commentedon Jun 18, 2025
I suspect we are relying on this behavior:
We probably need to define a stricter type of equality.
Write chunks with negative zero values and a zero fill value
Write chunks with negative zero values and a zero fill value
Write chunks with negative zero values and a zero fill value
Write chunks with negative zero values and a zero fill value
Write chunks with negative zero values and a zero fill value (#3216)
perf: cut the fill_value check on the chunk write path
perf: cut the fill_value check on the chunk write path (#4382)