Skip to content
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

fix: implicit fill value initialisation #2799

Merged
merged 7 commits into from
Feb 12, 2025

Conversation

LDeakin
Copy link
Contributor

@LDeakin LDeakin commented Feb 5, 2025

Fixes omissions in #2274

  • initialise empty chunks to the default fill value during writing
  • add default fill value for datetime, timedelta, structured, and other (void* fixed size) data types
  • add test for "other" data type

Fixes the below:

array = zarr.create_array(
    store=zarr.storage.MemoryStore(),
    dtype=np.uint8,
    shape=(4,),
    chunks=(2,),
    fill_value=None,
    zarr_format=2,
)
array[:3] = [1, 2, 3]
print(array[:]) # [1, 2, 3, undefined]

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)

- initialise empty chunks to the default fill value during writing
- add default fill value for datetime, timedelta, structured data types
@github-actions github-actions bot added the needs release notes Automatically applied to PRs which haven't added release notes label Feb 5, 2025
@@ -349,6 +349,14 @@ def _default_fill_value(dtype: np.dtype[Any]) -> Any:
return b""
elif dtype.kind in "UO":
return ""
elif dtype.kind in "Mm":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could use some keen eyes, I've never used these dtypes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also unfamiliar with those dtypes. perhaps you could find examples from the tests on the v2 branch?

@github-actions github-actions bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Feb 10, 2025
@d-v-b d-v-b enabled auto-merge (squash) February 12, 2025 09:28
@d-v-b d-v-b merged commit c66f32b into zarr-developers:main Feb 12, 2025
29 of 30 checks passed
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.

2 participants