Skip to content

Fix nan encoding in consolidated metadata #2996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 18, 2025

Conversation

mpiannucci
Copy link
Contributor

@mpiannucci mpiannucci commented Apr 17, 2025

Fixes #2990 by reusing the special character replacement before encoding the same as the v3 metadata does

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.rst
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@github-actions github-actions bot added the needs release notes Automatically applied to PRs which haven't added release notes label Apr 17, 2025
@github-actions github-actions bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Apr 18, 2025
Copy link
Contributor

@d-v-b d-v-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good, thanks!

@d-v-b d-v-b requested a review from TomAugspurger April 18, 2025 14:40
Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do wonder if something like #2144 would mean we don't need this workaround, but this looks good for now.

@TomAugspurger TomAugspurger merged commit 84d3284 into zarr-developers:main Apr 18, 2025
30 checks passed
d-v-b added a commit to d-v-b/zarr-python that referenced this pull request Apr 20, 2025
* Fix nan encoding in consolidated metadata

Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
@@ -355,10 +355,10 @@ def to_buffer_dict(self, prototype: BufferPrototype) -> dict[str, Buffer]:
assert isinstance(consolidated_metadata, dict)
for k, v in consolidated_metadata.items():
attrs = v.pop("attributes", None)
d[f"{k}/{ZATTRS_JSON}"] = attrs
d[f"{k}/{ZATTRS_JSON}"] = _replace_special_floats(attrs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mpiannucci was this particular change important? Given that the "special floats" logic is very narrowly scoped to array metadata, I don't think we want to apply it to the attributes.

I'm just seeing this now as I adapt #2874 to the latest changes.

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.

Consolidated Metadata serializes NaN incorrectly
3 participants