Skip to content

Commit 05891be

Browse files
authored
Merge branch 'main' into fix/consistent-create-array-signature
2 parents 0c7f64a + 0dd797f commit 05891be

File tree

29 files changed

+130
-81
lines changed

29 files changed

+130
-81
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,22 @@ body:
5757
id: reproduce
5858
attributes:
5959
label: Steps to reproduce
60-
description: Minimal, reproducible code sample, a copy-pastable example if possible.
60+
description: Minimal, reproducible code sample. Must list dependencies in [inline script metadata](https://packaging.python.org/en/latest/specifications/inline-script-metadata/#example). When put in a file named `issue.py` calling `uv run issue.py` should show the issue.
61+
value: |
62+
```python
63+
# /// script
64+
# requires-python = ">=3.11"
65+
# dependencies = [
66+
# "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",
67+
# ]
68+
# ///
69+
#
70+
# This script automatically imports the development branch of zarr to check for issues
71+
72+
import zarr
73+
# your reproducer code
74+
# zarr.print_debug_info()
75+
```
6176
validations:
6277
required: true
6378
- type: textarea

changes/3081.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adds ``fill_value`` to the list of attributes displayed in the output of the ``AsyncArray.info()`` method.

changes/3082.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use :py:func:`numpy.zeros` instead of :py:func:`np.full` for a performance speedup when creating a `zarr.core.buffer.NDBuffer` with `fill_value=0`.

docs/user-guide/arrays.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ which can be used to print useful diagnostics, e.g.::
183183
Type : Array
184184
Zarr format : 3
185185
Data type : DataType.int32
186+
Fill value : 0
186187
Shape : (10000, 10000)
187188
Chunk shape : (1000, 1000)
188189
Order : C
@@ -200,6 +201,7 @@ prints additional diagnostics, e.g.::
200201
Type : Array
201202
Zarr format : 3
202203
Data type : DataType.int32
204+
Fill value : 0
203205
Shape : (10000, 10000)
204206
Chunk shape : (1000, 1000)
205207
Order : C
@@ -287,6 +289,7 @@ Here is an example using a delta filter with the Blosc compressor::
287289
Type : Array
288290
Zarr format : 3
289291
Data type : DataType.int32
292+
Fill value : 0
290293
Shape : (10000, 10000)
291294
Chunk shape : (1000, 1000)
292295
Order : C
@@ -601,6 +604,7 @@ Sharded arrays can be created by providing the ``shards`` parameter to :func:`za
601604
Type : Array
602605
Zarr format : 3
603606
Data type : DataType.uint8
607+
Fill value : 0
604608
Shape : (10000, 10000)
605609
Shard shape : (1000, 1000)
606610
Chunk shape : (100, 100)

docs/user-guide/groups.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ property. E.g.::
129129
Type : Array
130130
Zarr format : 3
131131
Data type : DataType.int64
132+
Fill value : 0
132133
Shape : (1000000,)
133134
Chunk shape : (100000,)
134135
Order : C
@@ -145,6 +146,7 @@ property. E.g.::
145146
Type : Array
146147
Zarr format : 3
147148
Data type : DataType.float32
149+
Fill value : 0.0
148150
Shape : (1000, 1000)
149151
Chunk shape : (100, 100)
150152
Order : C

docs/user-guide/performance.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ To use sharding, you need to specify the ``shards`` parameter when creating the
9292
Type : Array
9393
Zarr format : 3
9494
Data type : DataType.uint8
95+
Fill value : 0
9596
Shape : (10000, 10000, 1000)
9697
Shard shape : (1000, 1000, 1000)
9798
Chunk shape : (100, 100, 100)
@@ -122,6 +123,7 @@ ratios, depending on the correlation structure within the data. E.g.::
122123
Type : Array
123124
Zarr format : 3
124125
Data type : DataType.int32
126+
Fill value : 0
125127
Shape : (10000, 10000)
126128
Chunk shape : (1000, 1000)
127129
Order : C
@@ -141,6 +143,7 @@ ratios, depending on the correlation structure within the data. E.g.::
141143
Type : Array
142144
Zarr format : 3
143145
Data type : DataType.int32
146+
Fill value : 0
144147
Shape : (10000, 10000)
145148
Chunk shape : (1000, 1000)
146149
Order : F

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ extend-exclude = [
291291
extend-select = [
292292
"ANN", # flake8-annotations
293293
"B", # flake8-bugbear
294-
"EXE", # flake8-executable
295294
"C4", # flake8-comprehensions
295+
"EXE", # flake8-executable
296296
"FA", # flake8-future-annotations
297297
"FLY", # flynt
298298
"FURB", # refurb
@@ -364,14 +364,14 @@ module = [
364364
"tests.test_store.test_local",
365365
"tests.test_store.test_fsspec",
366366
"tests.test_store.test_memory",
367+
"tests.test_codecs.test_codecs",
367368
]
368369
strict = false
369370

370371
# TODO: Move the next modules up to the strict = false section
371372
# and fix the errors
372373
[[tool.mypy.overrides]]
373374
module = [
374-
"tests.test_codecs.test_codecs",
375375
"tests.test_metadata.*",
376376
"tests.test_store.test_core",
377377
"tests.test_store.test_logging",

src/zarr/api/asynchronous.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ async def open(
329329
try:
330330
metadata_dict = await get_array_metadata(store_path, zarr_format=zarr_format)
331331
# TODO: remove this cast when we fix typing for array metadata dicts
332-
_metadata_dict = cast(ArrayMetadataDict, metadata_dict)
332+
_metadata_dict = cast("ArrayMetadataDict", metadata_dict)
333333
# for v2, the above would already have raised an exception if not an array
334334
zarr_format = _metadata_dict["zarr_format"]
335335
is_v3_array = zarr_format == 3 and _metadata_dict.get("node_type") == "array"

src/zarr/codecs/crc32c_.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ async def _decode_single(
4040
inner_bytes = data[:-4]
4141

4242
# Need to do a manual cast until https://github.com/numpy/numpy/issues/26783 is resolved
43-
computed_checksum = np.uint32(crc32c(cast(typing_extensions.Buffer, inner_bytes))).tobytes()
43+
computed_checksum = np.uint32(
44+
crc32c(cast("typing_extensions.Buffer", inner_bytes))
45+
).tobytes()
4446
stored_checksum = bytes(crc32_bytes)
4547
if computed_checksum != stored_checksum:
4648
raise ValueError(
@@ -55,7 +57,7 @@ async def _encode_single(
5557
) -> Buffer | None:
5658
data = chunk_bytes.as_numpy_array()
5759
# Calculate the checksum and "cast" it to a numpy array
58-
checksum = np.array([crc32c(cast(typing_extensions.Buffer, data))], dtype=np.uint32)
60+
checksum = np.array([crc32c(cast("typing_extensions.Buffer", data))], dtype=np.uint32)
5961
# Append the checksum (as bytes) to the data
6062
return chunk_spec.prototype.buffer.from_array_like(np.append(data, checksum.view("B")))
6163

src/zarr/codecs/sharding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class _ShardIndex(NamedTuple):
115115
def chunks_per_shard(self) -> ChunkCoords:
116116
result = tuple(self.offsets_and_lengths.shape[0:-1])
117117
# The cast is required until https://github.com/numpy/numpy/pull/27211 is merged
118-
return cast(ChunkCoords, result)
118+
return cast("ChunkCoords", result)
119119

120120
def _localize_chunk(self, chunk_coords: ChunkCoords) -> ChunkCoords:
121121
return tuple(

0 commit comments

Comments
 (0)