Skip to content

Write chunks with negative zero values and a zero fill value #3216

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bojidar-bg
Copy link

@bojidar-bg bojidar-bg commented Jul 8, 2025

Fixes #3144.

Using np.any(self._data) was inspired by how Zarr v2 checks for equality with a falsey fill value.

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 Jul 8, 2025
@bojidar-bg bojidar-bg force-pushed the 3144-negative-zero branch from d4c1205 to 2745b68 Compare July 8, 2025 11:48
@github-actions github-actions bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Jul 8, 2025
@bojidar-bg bojidar-bg force-pushed the 3144-negative-zero branch from 2745b68 to 7d6d74b Compare July 8, 2025 11:49
@bojidar-bg
Copy link
Author

Oh, oops, thanks 😅

@bojidar-bg bojidar-bg force-pushed the 3144-negative-zero branch from 7d6d74b to c4904e3 Compare July 8, 2025 11:53
@d-v-b
Copy link
Contributor

d-v-b commented Jul 11, 2025

this test failure seems significant: https://github.com/zarr-developers/zarr-python/actions/runs/16172926021/job/45650861381?pr=3216#step:8:420

@dcherian
Copy link
Contributor

this test failure seems significant

Yes looks like this approach doesn't work for complex number types

@d-v-b
Copy link
Contributor

d-v-b commented Jul 11, 2025

what if we view the array as raw bytes (should be cheap) and compare the raw bytes?

>>> import numpy as np
>>> np.array([0.0]) == np.array([-0.0])
array([ True])
>>> np.array([0.0]).view('V') == np.array([-0.0]).view('V')
array([False])

@bojidar-bg
Copy link
Author

I wonder if that would somehow break with floating point subnormal-s and the like. Will have to experiment 🤔

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.

Negative zero not preserved
3 participants