-
-
Notifications
You must be signed in to change notification settings - Fork 346
[v3] fix: zarr v2 compatibility fixes for Dask #2186
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fe49f5f
fix: zarr v2 compatability fixes
jhamman 9a1580b
move zarr.store to zarr.storage
jhamman 0d89912
make chunks a tuple
jhamman d78e384
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman e534279
Apply suggestions from code review
jhamman dea4a3d
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman 7800f38
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman 93b61fc
more merge conflict resolution
jhamman 88afe52
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman fb6752d
fixups
jhamman 0b1dedc
fixup zipstore
jhamman 322918a
Apply suggestions from code review
jhamman a95d54a
Apply suggestions from code review
jhamman 128eb53
add test
jhamman 3c170ef
Merge branch 'v3' of https://github.com/zarr-developers/zarr-python i…
jhamman 54ab9ef
extend test
jhamman 77f2938
clean up parents
jhamman 2295d76
debug race condition
jhamman 5879d67
more debug
jhamman 3940d22
Update src/zarr/core/array.py
jhamman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,12 @@ | |
|
||
import itertools | ||
import math | ||
import numbers | ||
import operator | ||
from abc import abstractmethod | ||
from dataclasses import dataclass | ||
from functools import reduce | ||
from typing import TYPE_CHECKING | ||
from typing import TYPE_CHECKING, Any | ||
|
||
import numpy as np | ||
|
||
|
@@ -98,6 +99,50 @@ def _guess_chunks( | |
return tuple(int(x) for x in chunks) | ||
|
||
|
||
def normalize_chunks(chunks: Any, shape: tuple[int, ...], typesize: int) -> tuple[int, ...]: | ||
"""Convenience function to normalize the `chunks` argument for an array | ||
with the given `shape`.""" | ||
|
||
# N.B., expect shape already normalized | ||
|
||
# handle auto-chunking | ||
if chunks is None or chunks is True: | ||
d-v-b marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return _guess_chunks(shape, typesize) | ||
|
||
# handle no chunking | ||
if chunks is False: | ||
return shape | ||
|
||
# handle 1D convenience form | ||
if isinstance(chunks, numbers.Integral): | ||
chunks = tuple(int(chunks) for _ in shape) | ||
|
||
# handle dask-style chunks (iterable of iterables) | ||
if all(isinstance(c, (tuple | list)) for c in chunks): | ||
# take first chunk size for each dimension | ||
chunks = ( | ||
c[0] for c in chunks | ||
) # TODO: check/error/warn for irregular chunks (e.g. if c[0] != c[1:-1]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. except for this block, the rest of this function came from 2.x |
||
|
||
# handle bad dimensionality | ||
if len(chunks) > len(shape): | ||
raise ValueError("too many dimensions in chunks") | ||
|
||
# handle underspecified chunks | ||
if len(chunks) < len(shape): | ||
# assume chunks across remaining dimensions | ||
chunks += shape[len(chunks) :] | ||
|
||
# handle None or -1 in chunks | ||
if -1 in chunks or None in chunks: | ||
chunks = tuple( | ||
s if c == -1 or c is None else int(c) for s, c in zip(shape, chunks, strict=False) | ||
) | ||
|
||
out = tuple(int(c) for c in chunks) | ||
return out | ||
|
||
|
||
@dataclass(frozen=True) | ||
class ChunkGrid(Metadata): | ||
@classmethod | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.