-
-
Notifications
You must be signed in to change notification settings - Fork 308
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
Parse chunk shape to check for float values #2535
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, thank you
src/zarr/core/array.py
Outdated
chunks = parse_shapelike(chunks) | ||
_chunks = normalize_chunks(chunks, shape, dtype_parsed.itemsize) | ||
else: | ||
if chunk_shape: | ||
chunk_shape = parse_shapelike(chunk_shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we move this check into normalize_chunks
. Here's where the behavior you're looking to change is:
zarr-python/src/zarr/core/chunk_grids.py
Lines 116 to 117 in 2fe12a7
if isinstance(chunks, numbers.Integral): | |
chunks = tuple(int(chunks) for _ in shape) |
If you look at normalize_chunks
, you'll see why Zarr is more permissive on chunk shape than array shape. I'm not opposed to us disallowing floats but we need to be careful keep some of the other behaviors in normalize_chunks
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like a better place indeed! I've updated the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @faymanns for working on this. I left one comment to direct your attention to normalize_chunks
This PR solves the fact that specifying a chunk shape containing one or several float values does not raise an error.
Before the PR the values after the decimal point are trimmed without a warning.
After the PR a
TypeError
is raised when the chunk shape contains float values.It solves issue #2530.
TODO: