fix: compare metadata objects by JSON form#3999
Merged
Merged
Conversation
Frozen dataclass __eq__ compared fill_value directly, so two identical metadata objects with a NaN fill value compared unequal (NaN != NaN under IEEE 754). Compare the JSON-serialized form instead, which treats matching NaN and infinite fill values as equal. Fixes zarr-developers#2929 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
TomNicholas
approved these changes
May 22, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3999 +/- ##
=======================================
Coverage 93.49% 93.49%
=======================================
Files 88 88
Lines 11861 11873 +12
=======================================
+ Hits 11089 11101 +12
Misses 772 772
🚀 New features to boost your workflow:
|
dcherian
approved these changes
May 22, 2026
Member
|
@d-v-b are you surprised by the codspeed analysis results from https://github.com/zarr-developers/zarr-python/runs/77699725053? |
Contributor
Author
|
I am surprised! we should see if it's due to changes in this PR (which I doubt) or instead changes that we merged recently without a baseline benchmark. |
Contributor
Author
|
the cause was loss of morton order caching in #3826, we should get our perf back when we bring back the caching |
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.
this PR makes
__eq__and__hash__use the JSON form of array / group metadata objects, which means two metadata objects withfill_value=NaNwill compare as equal, because the string form of the fill value will be used in the comparison.This change makes our metadata objects hashable on the string form of the JSON representation. We can use a simpler form of hashing in the future if we go all-in on immutable data structures like frozendict here.
(finally) closes #2929