Skip to content

fix: handle special uint32 arrays on Windows correctly#3797

Merged
d-v-b merged 3 commits intozarr-developers:mainfrom
radoering:fix-uint32-win32
Mar 21, 2026
Merged

fix: handle special uint32 arrays on Windows correctly#3797
d-v-b merged 3 commits intozarr-developers:mainfrom
radoering:fix-uint32-win32

Conversation

@radoering
Copy link
Contributor

@radoering radoering commented Mar 20, 2026

Resolves: #3796

Changes are equivalent to #3151 just for uint32.

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/*.md
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

# On Windows, this creates an UIntDType (instead of UInt32DType),
# similar to how np.dtype('i') creates an IntDType instead of Int32DType.
# However, np.dtype('u') raises a TypeError.
uint_dtype = (np.array([1], dtype=np.uint32) & 1).dtype
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the & 1 for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To create the special dtype. Without the & 1, it is UInt32Dtype, with & 1, it is UIntDtype.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, thanks for the clarification. Why is numpy doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no idea. It took me a while to figure out how to create an array with such a dtype after I encountered this error in more complex code.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes I can imagine how frustrating that must have been. if this happens again we might need to consider relying on some kind of structural checks instead of trusting numpy's class hierarchy.

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 looking for reports of this on the numpy issue tracker, this one seems related: numpy/numpy#17351

@d-v-b d-v-b enabled auto-merge (squash) March 21, 2026 19:12
@d-v-b d-v-b merged commit 93dd0e4 into zarr-developers:main Mar 21, 2026
23 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.

ValueError: No Zarr data type found that matches dtype 'dtype('uint32')' on Windows

2 participants