Skip to content

fix: handle special uint32 arrays on Windows correctly#3797

Open
radoering wants to merge 2 commits intozarr-developers:mainfrom
radoering:fix-uint32-win32
Open

fix: handle special uint32 arrays on Windows correctly#3797
radoering wants to merge 2 commits intozarr-developers:mainfrom
radoering:fix-uint32-win32

Conversation

@radoering
Copy link

@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
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
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

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