Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ default_language_version:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
rev: v0.15.4
hooks:
- id: ruff-check
args: ["--fix", "--show-fixes"]
Expand Down
6 changes: 3 additions & 3 deletions src/zarr/_cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from enum import Enum
from enum import StrEnum
from typing import Annotated, Literal, cast

import typer
Expand All @@ -24,12 +24,12 @@ def _set_logging_level(*, verbose: bool) -> None:
zarr.set_format("%(message)s")


class CLIZarrFormat(str, Enum):
class CLIZarrFormat(StrEnum):
v2 = "v2"
v3 = "v3"


class CLIZarrFormatV3(str, Enum):
class CLIZarrFormatV3(StrEnum):
"""Limit CLI choice to only v3"""

v3 = "v3"
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/core/chunk_key_encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ChunkKeyEncoding(ABC, Metadata):
@classmethod
def from_dict(cls, data: dict[str, JSON]) -> Self:
_, config_parsed = parse_named_configuration(data, require_configuration=False)
return cls(**config_parsed if config_parsed else {})
return cls(**config_parsed or {})

def to_dict(self) -> dict[str, JSON]:
return {"name": self.name, "configuration": super().to_dict()}
Expand Down
1 change: 0 additions & 1 deletion src/zarr/core/dtype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
"TBaseDType",
"TBaseScalar",
"TimeDelta64",
"TimeDelta64",
"TimeDelta64JSON_V2",
"TimeDelta64JSON_V3",
"UInt8",
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _iter_regions(
# ((slice(0, 1, 1), slice(0, 2, 1)), (slice(1, 2, 1), slice(0, 2, 1)))
```
"""
grid_shape = tuple(ceildiv(d, s) for d, s in zip(domain_shape, region_shape, strict=True))
grid_shape = tuple(itertools.starmap(ceildiv, zip(domain_shape, region_shape, strict=True)))
for grid_position in _iter_grid(
grid_shape=grid_shape, origin=origin, selection_shape=selection_shape, order=order
):
Expand Down
2 changes: 0 additions & 2 deletions src/zarr/dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"StructuredJSON_V2",
"StructuredJSON_V3",
"TimeDelta64",
"TimeDelta64",
"TimeDelta64JSON_V2",
"TimeDelta64JSON_V3",
"UInt8",
Expand All @@ -85,6 +84,5 @@
"VariableLengthUTF8JSON_V2",
"ZDType",
"data_type_registry",
"data_type_registry",
"parse_dtype",
]
2 changes: 2 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,7 @@ def test_auto_chunks(f: Callable[..., AnyArray]) -> None:
array = np.zeros(shape, dtype=dtype)
store = zarr.storage.MemoryStore()

# ruff: disable[FURB171]
if f in [zarr.full, zarr.full_like]:
kwargs["fill_value"] = 0
if f in [zarr.array]:
Expand All @@ -1537,6 +1538,7 @@ def test_auto_chunks(f: Callable[..., AnyArray]) -> None:
kwargs["a"] = array
if f in [zarr.create_array]:
kwargs["store"] = store
# ruff: enable[FURB171]

a = f(**kwargs)
assert a.chunks == (500, 500)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pickle
import re
import sys
from itertools import accumulate
from itertools import accumulate, starmap
from typing import TYPE_CHECKING, Any, Literal
from unittest import mock

Expand Down Expand Up @@ -2064,12 +2064,12 @@ def test_chunk_grid_shape(
zarr_format=zarr_format,
)

chunk_grid_shape = tuple(ceildiv(a, b) for a, b in zip(array_shape, chunk_shape, strict=True))
chunk_grid_shape = tuple(starmap(ceildiv, zip(array_shape, chunk_shape, strict=True)))
if shard_shape is None:
_shard_shape = chunk_shape
else:
_shard_shape = shard_shape
shard_grid_shape = tuple(ceildiv(a, b) for a, b in zip(array_shape, _shard_shape, strict=True))
shard_grid_shape = tuple(starmap(ceildiv, zip(array_shape, _shard_shape, strict=True)))
assert arr._chunk_grid_shape == chunk_grid_shape
assert arr.cdata_shape == chunk_grid_shape
assert arr.async_array.cdata_shape == chunk_grid_shape
Expand Down
2 changes: 1 addition & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_script_paths() -> None:


@pytest.mark.skipif(
sys.platform in ("win32",), reason="This test fails due for unknown reasons on Windows in CI."
sys.platform == "win32", reason="This test fails due for unknown reasons on Windows in CI."
Comment thread
d-v-b marked this conversation as resolved.
Outdated
)
@pytest.mark.parametrize("script_path", script_paths)
def test_scripts_can_run(script_path: Path, tmp_path: Path) -> None:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_properties.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import itertools
import json
import numbers
from typing import Any
Expand Down Expand Up @@ -60,7 +61,7 @@ def deep_equal(a: Any, b: Any) -> bool:
if isinstance(a, np.ndarray) and isinstance(b, np.ndarray):
if a.shape != b.shape:
return False
return all(deep_equal(x, y) for x, y in zip(a.flat, b.flat, strict=False))
return all(itertools.starmap(deep_equal, zip(a.flat, b.flat, strict=False)))

if isinstance(a, dict) and isinstance(b, dict):
if set(a.keys()) != set(b.keys()):
Expand All @@ -70,7 +71,7 @@ def deep_equal(a: Any, b: Any) -> bool:
if isinstance(a, (list, tuple)) and isinstance(b, (list, tuple)):
if len(a) != len(b):
return False
return all(deep_equal(x, y) for x, y in zip(a, b, strict=False))
return all(itertools.starmap(deep_equal, zip(a, b, strict=False)))

return a == b

Expand Down
Loading