-
-
Notifications
You must be signed in to change notification settings - Fork 323
refactor v3 data types #2874
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
base: main
Are you sure you want to change the base?
refactor v3 data types #2874
Changes from 21 commits
f5e3f78
b4e71e2
3c50f54
d74e7a4
5000dcb
9cd5c51
042fac1
556e390
b588f70
4ed41c6
1b2c773
24930b3
703e0e1
3c232a4
b7fe986
d9b44b4
bf24d69
c1a8566
2868994
9ab0b1e
e9f5e26
6df84a9
e14279d
381a264
6a7857b
e8fd72c
b22f324
b7a231e
7dfcd0f
706e6b6
8fbf673
e9aff64
44e78f5
60cac04
120df57
0d9922b
2075952
44369d6
4f3381f
c8d7680
2a7b5a8
e855e54
a2da99a
5ea3fa4
cbb159d
c506d09
bb11867
7a619e0
ea2d0bf
042c9e5
def5eb2
1b7273b
60b2e9d
83f508c
4ceb6ed
5b9cff0
65f0453
cb0a7d4
40f0063
9989c64
a276c84
6285739
e9241b9
2bffe1a
aa32271
617d3f0
2b5fd8f
1831f20
a427a16
41d7e58
c08ffd9
778d740
269215e
8af0ce4
df60d05
7f54bbf
be83f03
8e6924d
25b1527
0a5d14e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
get_indexer, | ||
morton_order_iter, | ||
) | ||
from zarr.core.metadata.dtype import DTypeWrapper | ||
from zarr.core.metadata.v3 import parse_codecs | ||
from zarr.registry import get_ndbuffer_class, get_pipeline_class, register_codec | ||
|
||
|
@@ -355,9 +356,10 @@ def __init__( | |
object.__setattr__(self, "index_location", index_location_parsed) | ||
|
||
# Use instance-local lru_cache to avoid memory leaks | ||
object.__setattr__(self, "_get_chunk_spec", lru_cache()(self._get_chunk_spec)) | ||
object.__setattr__(self, "_get_index_chunk_spec", lru_cache()(self._get_index_chunk_spec)) | ||
object.__setattr__(self, "_get_chunks_per_shard", lru_cache()(self._get_chunks_per_shard)) | ||
# TODO: fix these when we don't get hashability errors for certain numpy dtypes | ||
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. note to fix this. I think the LRU store cache was attempting to hash a non-hashable numpy dtype, and this caused very hard to debug errors. 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. Would be good to open an issue and link to it in this comment. 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. Is this something that needs fixing before this PR is merged? |
||
# object.__setattr__(self, "_get_chunk_spec", lru_cache()(self._get_chunk_spec)) | ||
# object.__setattr__(self, "_get_index_chunk_spec", lru_cache()(self._get_index_chunk_spec)) | ||
# object.__setattr__(self, "_get_chunks_per_shard", lru_cache()(self._get_chunks_per_shard)) | ||
|
||
# todo: typedict return type | ||
def __getstate__(self) -> dict[str, Any]: | ||
|
@@ -402,7 +404,9 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self: | |
return replace(self, codecs=evolved_codecs) | ||
return self | ||
|
||
def validate(self, *, shape: ChunkCoords, dtype: np.dtype[Any], chunk_grid: ChunkGrid) -> None: | ||
def validate( | ||
self, *, shape: ChunkCoords, dtype: DTypeWrapper[Any, Any], chunk_grid: ChunkGrid | ||
) -> None: | ||
if len(self.chunk_shape) != len(shape): | ||
raise ValueError( | ||
"The shard's `chunk_shape` and array's `shape` need to have the same number of dimensions." | ||
|
@@ -483,7 +487,10 @@ async def _decode_partial_single( | |
|
||
# setup output array | ||
out = shard_spec.prototype.nd_buffer.create( | ||
shape=indexer.shape, dtype=shard_spec.dtype, order=shard_spec.order, fill_value=0 | ||
shape=indexer.shape, | ||
dtype=shard_spec.dtype.unwrap(), | ||
order=shard_spec.order, | ||
fill_value=0, | ||
) | ||
|
||
indexed_chunks = list(indexer) | ||
|
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.
calling
to_dtype
here would help avoid having to call it twice below.