Skip to content

Commit 2561669

Browse files
authored
Merge branch 'main' into feat/memory-store-registry
2 parents a959c0a + fa61ed8 commit 2561669

6 files changed

Lines changed: 42 additions & 6 deletions

File tree

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ repos:
5454
rev: v1.10.0
5555
hooks:
5656
- id: numpydoc-validation
57+
- repo: local
58+
hooks:
59+
- id: ban-lstrip-rstrip
60+
name: ban lstrip/rstrip
61+
language: pygrep
62+
# Matches .lstrip() or .rstrip() where the string argument is 2+ characters.
63+
entry: "\\.(lstrip|rstrip)\\([\"'][^\"']{2,}[\"']\\)"
64+
types: [python]
65+
files: ^(src|tests)/
5766
- repo: https://github.com/twisted/towncrier
5867
rev: 25.8.0
5968
hooks:

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
@@ -223,6 +223,13 @@ print(z.info_complete())
223223
If you don't specify a compressor, by default Zarr uses the Zstandard
224224
compressor.
225225

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

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)