Skip to content

Commit 60192ee

Browse files
authored
Merge branch 'main' into feat/global-concurrency-limit
2 parents f2d8633 + a02d996 commit 60192ee

6 files changed

Lines changed: 52 additions & 12 deletions

File tree

changes/3464.doc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add documentation example for creating uncompressed arrays in the Compression section of the user guide.

docs/overrides/stylesheets/extra.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@
5252
color: white;
5353
}
5454

55-
/* Search box styling */
56-
.md-search__input {
55+
/* Search box styling in the header */
56+
.md-header .md-search__input {
5757
background-color: rgba(255, 255, 255, 0.15);
5858
border: 1px solid rgba(255, 255, 255, 0.2);
5959
color: white;
6060
}
6161

62-
.md-search__input::placeholder {
62+
.md-header .md-search__input::placeholder {
6363
color: rgba(255, 255, 255, 0.7);
6464
}
6565

docs/user-guide/arrays.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ print(z.info_complete())
224224
If you don't specify a compressor, by default Zarr uses the Zstandard
225225
compressor.
226226

227+
To create an array without any compression, set `compressors=None`:
228+
229+
```python exec="true" session="arrays" source="above" result="ansi"
230+
z_no_compress = zarr.create_array(store='data/example-uncompressed.zarr', shape=(10000, 10000), chunks=(1000, 1000), dtype='int32', compressors=None)
231+
print(f"Compressors: {z_no_compress.compressors}")
232+
```
233+
227234
In addition to Blosc and Zstandard, other compression libraries can also be used. For example,
228235
here is an array using Gzip compression, level 1:
229236

src/zarr/core/array.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,24 +1234,28 @@ def basename(self) -> str:
12341234
@property
12351235
def cdata_shape(self) -> tuple[int, ...]:
12361236
"""
1237-
The shape of the chunk grid for this array.
1237+
The number of chunks along each dimension.
1238+
1239+
When sharding is used, this counts inner chunks (not shards) per dimension.
12381240
12391241
Returns
12401242
-------
12411243
tuple[int, ...]
1242-
The shape of the chunk grid for this array.
1244+
The number of chunks along each dimension.
12431245
"""
12441246
return self._chunk_grid_shape
12451247

12461248
@property
12471249
def _chunk_grid_shape(self) -> tuple[int, ...]:
12481250
"""
1249-
The shape of the chunk grid for this array.
1251+
The number of chunks along each dimension.
1252+
1253+
When sharding is used, this counts inner chunks (not shards) per dimension.
12501254
12511255
Returns
12521256
-------
12531257
tuple[int, ...]
1254-
The shape of the chunk grid for this array.
1258+
The number of chunks along each dimension.
12551259
"""
12561260
return tuple(starmap(ceildiv, zip(self.shape, self.chunks, strict=True)))
12571261

@@ -2398,14 +2402,23 @@ def compressors(self) -> tuple[Numcodec, ...] | tuple[BytesBytesCodec, ...]:
23982402
@property
23992403
def cdata_shape(self) -> tuple[int, ...]:
24002404
"""
2401-
The shape of the chunk grid for this array.
2405+
The number of chunks along each dimension.
2406+
2407+
When sharding is used, this counts inner chunks (not shards) per dimension.
24022408
"""
24032409
return self.async_array._chunk_grid_shape
24042410

24052411
@property
24062412
def _chunk_grid_shape(self) -> tuple[int, ...]:
24072413
"""
2408-
The shape of the chunk grid for this array.
2414+
The number of chunks along each dimension.
2415+
2416+
When sharding is used, this counts inner chunks (not shards) per dimension.
2417+
2418+
Returns
2419+
-------
2420+
tuple[int, ...]
2421+
The number of chunks along each dimension.
24092422
"""
24102423
return self.async_array._chunk_grid_shape
24112424

src/zarr/core/dtype/npy/float.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ def _check_scalar(self, data: object) -> TypeGuard[FloatLike]:
201201
TypeGuard[FloatLike]
202202
True if the input is a valid scalar value, False otherwise.
203203
"""
204+
if isinstance(data, str):
205+
# Only accept strings that are valid float representations (e.g. "NaN", "inf").
206+
# Plain strings that cannot be converted should return False so that cast_scalar
207+
# raises TypeError rather than a confusing ValueError.
208+
try:
209+
self.to_native_dtype().type(data)
210+
except (ValueError, OverflowError):
211+
return False
212+
else:
213+
return True
204214
return isinstance(data, FloatLike)
205215

206216
def _cast_scalar_unchecked(self, data: FloatLike) -> TFloatScalar_co:

tests/test_dtype/test_npy/test_float.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ class TestFloat16(_BaseTestFloat):
6565
(Float16(), -1.0, np.float16(-1.0)),
6666
(Float16(), "NaN", np.float16("NaN")),
6767
)
68-
invalid_scalar_params = ((Float16(), {"set!"}),)
68+
invalid_scalar_params = (
69+
(Float16(), {"set!"}),
70+
(Float16(), "not_a_float"),
71+
)
6972
hex_string_params = (("0x7fc0", np.nan), ("0x7fc1", np.nan), ("0x3c00", 1.0))
7073
item_size_params = (Float16(),)
7174

@@ -113,7 +116,10 @@ class TestFloat32(_BaseTestFloat):
113116
(Float32(), -1.0, np.float32(-1.0)),
114117
(Float32(), "NaN", np.float32("NaN")),
115118
)
116-
invalid_scalar_params = ((Float32(), {"set!"}),)
119+
invalid_scalar_params = (
120+
(Float32(), {"set!"}),
121+
(Float32(), "not_a_float"),
122+
)
117123
hex_string_params = (("0x7fc00000", np.nan), ("0x7fc00001", np.nan), ("0x3f800000", 1.0))
118124
item_size_params = (Float32(),)
119125

@@ -160,7 +166,10 @@ class TestFloat64(_BaseTestFloat):
160166
(Float64(), -1.0, np.float64(-1.0)),
161167
(Float64(), "NaN", np.float64("NaN")),
162168
)
163-
invalid_scalar_params = ((Float64(), {"set!"}),)
169+
invalid_scalar_params = (
170+
(Float64(), {"set!"}),
171+
(Float64(), "not_a_float"),
172+
)
164173
hex_string_params = (
165174
("0x7ff8000000000000", np.nan),
166175
("0x7ff8000000000001", np.nan),

0 commit comments

Comments
 (0)