Skip to content

Commit ba09040

Browse files
authored
Merge branch 'main' into kyle/object-store
2 parents 4465402 + feeb08f commit ba09040

File tree

26 files changed

+375
-114
lines changed

26 files changed

+375
-114
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545

4646
steps:
4747
- uses: actions/checkout@v4
48+
with:
49+
fetch-depth: 0 # grab all branches and tags
4850
- name: Set up Python
4951
uses: actions/setup-python@v5
5052
with:
@@ -82,6 +84,8 @@ jobs:
8284
dependency-set: upstream
8385
steps:
8486
- uses: actions/checkout@v4
87+
with:
88+
fetch-depth: 0
8589
- name: Set up Python
8690
uses: actions/setup-python@v5
8791
with:

changes/2755.bugfix.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The array returned by ``zarr.empty`` and an empty ``zarr.core.buffer.cpu.NDBuffer`` will now be filled with the
2+
specified fill value, or with zeros if no fill value is provided.
3+
This fixes a bug where Zarr format 2 data with no fill value was written with un-predictable chunk sizes.

changes/2758.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix zip-store path checking for stores with directories listed as files.

changes/2784.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid reading chunks during writes where possible. :issue:`757`

changes/2799.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enitialise empty chunks to the default fill value during writing and add default fill values for datetime, timedelta, structured, and other (void* fixed size) data types

changes/2811.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update numcodecs to not overwrite codec configuration ever. Closes :issue:`2800`.

src/zarr/abc/codec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ async def encode(
357357
@abstractmethod
358358
async def read(
359359
self,
360-
batch_info: Iterable[tuple[ByteGetter, ArraySpec, SelectorTuple, SelectorTuple]],
360+
batch_info: Iterable[tuple[ByteGetter, ArraySpec, SelectorTuple, SelectorTuple, bool]],
361361
out: NDBuffer,
362362
drop_axes: tuple[int, ...] = (),
363363
) -> None:
@@ -379,7 +379,7 @@ async def read(
379379
@abstractmethod
380380
async def write(
381381
self,
382-
batch_info: Iterable[tuple[ByteSetter, ArraySpec, SelectorTuple, SelectorTuple]],
382+
batch_info: Iterable[tuple[ByteSetter, ArraySpec, SelectorTuple, SelectorTuple, bool]],
383383
value: NDBuffer,
384384
drop_axes: tuple[int, ...] = (),
385385
) -> None:

src/zarr/api/asynchronous.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,8 @@ async def create(
10651065
async def empty(
10661066
shape: ChunkCoords, **kwargs: Any
10671067
) -> AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]:
1068-
"""Create an empty array.
1068+
"""Create an empty array with the specified shape. The contents will be filled with the
1069+
array's fill value or zeros if no fill value is provided.
10691070
10701071
Parameters
10711072
----------
@@ -1087,7 +1088,8 @@ async def empty(
10871088
async def empty_like(
10881089
a: ArrayLike, **kwargs: Any
10891090
) -> AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]:
1090-
"""Create an empty array like `a`.
1091+
"""Create an empty array like `a`. The contents will be filled with the
1092+
array's fill value or zeros if no fill value is provided.
10911093
10921094
Parameters
10931095
----------
@@ -1100,6 +1102,12 @@ async def empty_like(
11001102
-------
11011103
Array
11021104
The new array.
1105+
1106+
Notes
1107+
-----
1108+
The contents of an empty Zarr array are not defined. On attempting to
1109+
retrieve data from an empty Zarr array, any values may be returned,
1110+
and these are not guaranteed to be stable from one access to the next.
11031111
"""
11041112
like_kwargs = _like_args(a, kwargs)
11051113
return await empty(**like_kwargs)

src/zarr/api/synchronous.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,8 @@ def create_array(
902902

903903
# TODO: add type annotations for kwargs
904904
def empty(shape: ChunkCoords, **kwargs: Any) -> Array:
905-
"""Create an empty array.
905+
"""Create an empty array with the specified shape. The contents will be filled with the
906+
array's fill value or zeros if no fill value is provided.
906907
907908
Parameters
908909
----------
@@ -928,7 +929,8 @@ def empty(shape: ChunkCoords, **kwargs: Any) -> Array:
928929
# TODO: move ArrayLike to common module
929930
# TODO: add type annotations for kwargs
930931
def empty_like(a: ArrayLike, **kwargs: Any) -> Array:
931-
"""Create an empty array like another array.
932+
"""Create an empty array like another array. The contents will be filled with the
933+
array's fill value or zeros if no fill value is provided.
932934
933935
Parameters
934936
----------
@@ -941,6 +943,12 @@ def empty_like(a: ArrayLike, **kwargs: Any) -> Array:
941943
-------
942944
Array
943945
The new array.
946+
947+
Notes
948+
-----
949+
The contents of an empty Zarr array are not defined. On attempting to
950+
retrieve data from an empty Zarr array, any values may be returned,
951+
and these are not guaranteed to be stable from one access to the next.
944952
"""
945953
return Array(sync(async_api.empty_like(a, **kwargs)))
946954

src/zarr/codecs/sharding.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,9 @@ async def _decode_single(
455455
chunk_spec,
456456
chunk_selection,
457457
out_selection,
458+
is_complete_shard,
458459
)
459-
for chunk_coords, chunk_selection, out_selection in indexer
460+
for chunk_coords, chunk_selection, out_selection, is_complete_shard in indexer
460461
],
461462
out,
462463
)
@@ -486,7 +487,7 @@ async def _decode_partial_single(
486487
)
487488

488489
indexed_chunks = list(indexer)
489-
all_chunk_coords = {chunk_coords for chunk_coords, _, _ in indexed_chunks}
490+
all_chunk_coords = {chunk_coords for chunk_coords, *_ in indexed_chunks}
490491

491492
# reading bytes of all requested chunks
492493
shard_dict: ShardMapping = {}
@@ -524,8 +525,9 @@ async def _decode_partial_single(
524525
chunk_spec,
525526
chunk_selection,
526527
out_selection,
528+
is_complete_shard,
527529
)
528-
for chunk_coords, chunk_selection, out_selection in indexer
530+
for chunk_coords, chunk_selection, out_selection, is_complete_shard in indexer
529531
],
530532
out,
531533
)
@@ -558,8 +560,9 @@ async def _encode_single(
558560
chunk_spec,
559561
chunk_selection,
560562
out_selection,
563+
is_complete_shard,
561564
)
562-
for chunk_coords, chunk_selection, out_selection in indexer
565+
for chunk_coords, chunk_selection, out_selection, is_complete_shard in indexer
563566
],
564567
shard_array,
565568
)
@@ -601,8 +604,9 @@ async def _encode_partial_single(
601604
chunk_spec,
602605
chunk_selection,
603606
out_selection,
607+
is_complete_shard,
604608
)
605-
for chunk_coords, chunk_selection, out_selection in indexer
609+
for chunk_coords, chunk_selection, out_selection, is_complete_shard in indexer
606610
],
607611
shard_array,
608612
)

0 commit comments

Comments
 (0)