Repository navigation
Conversation
Two v2 array models compared unequal when their fill values were the same value written two ways. The canonical spelling of a v2 fill value now names the value NumPy stores for the dtype, because the v2 spec gives the dtype as a NumPy typestr: - a number for a float dtype is the float of the dtype's width that it reads as, written as a float64, so `0.1` and `0.10000000149011612` are one `<f4` value; - a `|S` value drops its trailing null bytes, and a `|S`, `|V` or struct value is encoded in base64 again, so `"QR=="` and `"QQ=="` are one value; - a `<U<n>` value is cut to `n` code points and drops its trailing `U+0000` code points. A `<U0` value is cut to one code point, because NumPy allocates an array of `U0` as an array of `U1`. For floats, `|S`, `|V` and structs this is also the spelling zarr-python 2.18.7 writes back. Which fill values a v2 dtype accepts is unchanged. The base64 checks and the `μs`/`us` unit, which both formats take from base64 and NumPy, are defined once in `zarr_metadata._numpy`. Each definition keeps its own rules and cites its own spec. Assisted-by: ClaudeCode:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The `cast_value` spec says an absent `rounding` means `"nearest-even"`, but a model that wrote it and one that left it out compared unequal. `without_defaults` and `with_defaults` build a `canonical` from the defaults of a configuration. They replace the hand-written functions of the v3 `zstd` and `sharding_indexed` codecs, of the `default` and `v2` chunk key encodings, and of the v2 `zlib`, `gzip`, `bz2`, `lzma`, `zstd`, `lz4` and `shuffle` codecs: a v3 definition drops a member written with its default, and a v2 codec writes each absent member, in the order numcodecs writes them. Assisted-by: ClaudeCode:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The `numpy.datetime64` and `numpy.timedelta64` specs say that `"us"` and `"μs"` are equivalent, but two v3 array models that differed only in that spelling compared unequal. The canonical configuration now writes `us`, as NumPy does. Assisted-by: ClaudeCode:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ue` rounding and `μs` Assisted-by: ClaudeCode:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Assisted-by: ClaudeCode:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Array models that describe the same array are now equal in three more cases. A v2 fill value is compared as the value NumPy stores for the dtype: for
<f4,0.1equals0.10000000149011612; for|S3,"YQ=="equals"YQAA", which only adds padding; for<U2,"abc"equals"ab"; and two base64 spellings of the same bytes are equal. A v3cast_valuecodec with aroundingofnearest-evenequals one without arounding. Anumpy.datetime64ornumpy.timedelta64with a unit ofμsequals one with a unit ofus.canonical_ofandcanonical_fill_valuewrite the one spelling in each case. Which documents are accepted has not changed.Stacked on #493 (
claude/audit-array-members-v3-480ed5, at e9f017a) and targets its branch. It stays a draft until #493 merges andmainis merged into this branch.Summary (agent)
5f352722fv2 fill values: canonical spelling follows what NumPy stores, checked against zarr-python 2.18.7. Acceptance is unchanged. Only base64 checks,μs=usandSnull padding are shared with v3 (_numpy.py); each definition cites its own spec.c9368233cwithout_defaults/with_defaults(internal) replace eleven hand-writtencanonicalfunctions;cast_valuegainsrounding="nearest-even".dfb6ca0d6v3 numpy time types canonicalizeμstous.83d7f4b33docs: Equality section ofdocs/models.md.8e0714fd7changelog fragment.Deliberate v2/v3 differences: v2 floats are spelled as the exact float64 zarr-python 2 writes (v3 writes the shortest number); v2
<Ucuts an over-long fill value as NumPy does (v3fixed_length_utf32refuses it).Review record (agent)
Four rounds, fresh reviewers each; rounds 3 and 4 found nothing serious.
Round 1 (full diff, two reviewers):
<U0fill values all canonicalized to""(serious, reproduced): fixed in5f352722f.5f352722f.μs: added indfb6ca0d6.5f352722f.c9368233c.out_of_rangediffers fromclamp: row added,c9368233c.Round 2 (full diff, two reviewers):
<U0"kept as written" rested on a false NumPy claim (serious, reproduced):<U0now read as one code point, as zarr-python 2 fills it,5f352722f.5f352722f.textfield could disagree withdefaults: derived in__post_init__,c9368233c.c9368233c,83d7f4b33.Round 3 (fix diff): no serious finding.
zstd/lzmacanonical members away from numcodecs' order (regression from the round 2 fix): sort removed, equality follows declared order,c9368233c.<U0docstring scoped to allocated arrays and unstored chunks:5f352722f.Round 4 (fix diff): no serious finding.
tests/v2/test_codecs.pynow compares order,c9368233c.without_defaultsequality is order-sensitive though its output is not (kept: one rule for both helpers).Not changed, found in review:
scale_offsetabsentoffset/scaleandcast_valueemptyscalar_mapstill compare unequal to their written defaults; v2|S/|V/struct refuse over-long or short fill values that zarr-python 2 cuts or pads.🤖 Generated with Claude Code