Skip to content

feat: Support for masked arrays (fixes #3744)#3816

Closed
abishop1990 wants to merge 2 commits intozarr-developers:mainfrom
abishop1990:issue-3744-masked-arrays-impl
Closed

feat: Support for masked arrays (fixes #3744)#3816
abishop1990 wants to merge 2 commits intozarr-developers:mainfrom
abishop1990:issue-3744-masked-arrays-impl

Conversation

@abishop1990
Copy link
Contributor

Adds support for numpy masked arrays in Zarr. When a masked array is provided to zarr.array(), it is automatically converted to a filled array with a warning that the mask is not preserved.

Changes

  • Added masked array detection in async array() function
  • Automatically convert masked arrays to filled arrays using .filled()
  • Added warning to inform users that the mask is not preserved
  • Added comprehensive tests for masked array support
  • Supports both Zarr v2 and v3 formats
  • Works with 1D, 2D, and higher-dimensional arrays

Tests

  • Handles basic masked arrays
  • Preserves unmasked values
  • Works with explicit dtype specifications
  • Works with explicit chunk specifications
  • Handles fully masked and partially masked arrays
  • Works with both Zarr v2 and v3 formats
  • Preserves dtype information
  • Respects custom fill values
  • Regular arrays remain unaffected

@d-v-b
Copy link
Contributor

d-v-b commented Mar 21, 2026

When a masked array is provided to zarr.array(), it is automatically converted to a filled array with a warning that the mask is not preserved.

Did someone request this particular solution? I suspect users of masked arrays want the ability to store a masked array, not a masked array with the mask removed.

@abishop1990
Copy link
Contributor Author

Closing: Implementation needs more comprehensive redesign. The linting issues suggest the approach needs rethinking. Deferring this feature to future sprint.

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