Skip to content

Commit bbc2536

Browse files
authored
Merge branch 'main' into remove-fsspec-path-check
2 parents a325217 + 926a52f commit bbc2536

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+528
-253
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ci:
66
default_stages: [pre-commit, pre-push]
77
repos:
88
- repo: https://github.com/astral-sh/ruff-pre-commit
9-
rev: v0.12.2
9+
rev: v0.12.7
1010
hooks:
1111
- id: ruff-check
1212
args: ["--fix", "--show-fixes"]
@@ -22,7 +22,7 @@ repos:
2222
- id: check-yaml
2323
- id: trailing-whitespace
2424
- repo: https://github.com/pre-commit/mirrors-mypy
25-
rev: v1.16.1
25+
rev: v1.17.1
2626
hooks:
2727
- id: mypy
2828
files: src|tests

changes/3098.misc.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Define Zarr-specific warning classes that subclass the Python built-in warnings.
2+
These classes makes it easier to control the visibility of warnings emitted by Zarr Python.
3+
See `zarr.errors` for these warning classes.

changes/3144.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ensure that -0.0 is not considered equal to 0.0 when checking if all the values in a chunk are equal to an array's fill value.```

codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ coverage:
33
patch:
44
default:
55
target: auto
6+
informational: true
67
project:
78
default:
89
target: auto

docs/user-guide/arrays.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ built-in delta filter::
238238

239239
>>> import lzma
240240
>>> from numcodecs.zarr3 import LZMA
241+
>>> import warnings
242+
>>> warnings.filterwarnings("ignore", category=UserWarning)
241243
>>>
242244
>>> lzma_filters = [dict(id=lzma.FILTER_DELTA, dist=4), dict(id=lzma.FILTER_LZMA2, preset=1)]
243245
>>> compressors = LZMA(filters=lzma_filters)

docs/user-guide/consolidated_metadata.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ In Python, the consolidated metadata is available on the ``.consolidated_metadat
2727
attribute of the ``GroupMetadata`` object.
2828

2929
>>> import zarr
30+
>>> import warnings
31+
>>> warnings.filterwarnings("ignore", category=UserWarning)
3032
>>>
3133
>>> store = zarr.storage.MemoryStore()
3234
>>> group = zarr.create_group(store=store)

pyproject.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -389,16 +389,6 @@ addopts = [
389389
]
390390
filterwarnings = [
391391
"error",
392-
# TODO: explicitly filter or catch the warnings below where we expect them to be emitted in the tests
393-
"ignore:Consolidated metadata is currently not part in the Zarr format 3 specification.*:UserWarning",
394-
"ignore:Creating a zarr.buffer.gpu.Buffer with an array that does not support the __cuda_array_interface__.*:UserWarning",
395-
"ignore:Automatic shard shape inference is experimental and may change without notice.*:UserWarning",
396-
"ignore:The codec .* is currently not part in the Zarr format 3 specification.*:UserWarning",
397-
"ignore:The dtype .* is currently not part in the Zarr format 3 specification.*:UserWarning",
398-
"ignore:Use zarr.create_array instead.:DeprecationWarning",
399-
"ignore:Duplicate name.*:UserWarning",
400-
"ignore:The `compressor` argument is deprecated. Use `compressors` instead.:UserWarning",
401-
"ignore:Numcodecs codecs are not in the Zarr version 3 specification and may not be supported by other zarr implementations.:UserWarning",
402392
"ignore:Unclosed client session <aiohttp.client.ClientSession.*:ResourceWarning"
403393
]
404394
markers = [

src/zarr/_compat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from inspect import Parameter, signature
55
from typing import Any, TypeVar
66

7+
from zarr.errors import ZarrFutureWarning
8+
79
T = TypeVar("T")
810

911
# Based off https://github.com/scikit-learn/scikit-learn/blob/e87b32a81c70abed8f2e97483758eb64df8255e9/sklearn/utils/validation.py#L63
@@ -54,7 +56,7 @@ def inner_f(*args: Any, **kwargs: Any) -> T:
5456
f"{version} passing these as positional arguments "
5557
"will result in an error"
5658
),
57-
FutureWarning,
59+
ZarrFutureWarning,
5860
stacklevel=2,
5961
)
6062
kwargs.update(zip(sig.parameters, args, strict=False))

src/zarr/api/asynchronous.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@
3939
create_hierarchy,
4040
)
4141
from zarr.core.metadata import ArrayMetadataDict, ArrayV2Metadata, ArrayV3Metadata
42-
from zarr.errors import GroupNotFoundError, NodeTypeValidationError
42+
from zarr.errors import (
43+
GroupNotFoundError,
44+
NodeTypeValidationError,
45+
ZarrDeprecationWarning,
46+
ZarrRuntimeWarning,
47+
ZarrUserWarning,
48+
)
4349
from zarr.storage import StorePath
4450
from zarr.storage._common import make_store_path
4551

@@ -141,7 +147,7 @@ def _like_args(a: ArrayLike, kwargs: dict[str, Any]) -> dict[str, Any]:
141147
else:
142148
# TODO: Remove type: ignore statement when type inference improves.
143149
# mypy cannot correctly infer the type of a.metadata here for some reason.
144-
new["codecs"] = a.metadata.codecs # type: ignore[unreachable]
150+
new["codecs"] = a.metadata.codecs
145151

146152
else:
147153
# TODO: set default values compressor/codecs
@@ -162,7 +168,7 @@ def _handle_zarr_version_or_format(
162168
)
163169
if zarr_version is not None:
164170
warnings.warn(
165-
"zarr_version is deprecated, use zarr_format", DeprecationWarning, stacklevel=2
171+
"zarr_version is deprecated, use zarr_format", ZarrDeprecationWarning, stacklevel=2
166172
)
167173
return zarr_version
168174
return zarr_format
@@ -228,7 +234,7 @@ async def consolidate_metadata(
228234
warnings.warn(
229235
"Consolidated metadata is currently not part in the Zarr format 3 specification. It "
230236
"may not be supported by other zarr implementations and may change in the future.",
231-
category=UserWarning,
237+
category=ZarrUserWarning,
232238
stacklevel=1,
233239
)
234240

@@ -536,7 +542,7 @@ async def save_group(
536542
await asyncio.gather(*aws)
537543

538544

539-
@deprecated("Use AsyncGroup.tree instead.")
545+
@deprecated("Use AsyncGroup.tree instead.", category=ZarrDeprecationWarning)
540546
async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None = None) -> Any:
541547
"""Provide a rich display of the hierarchy.
542548
@@ -674,13 +680,13 @@ async def group(
674680
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
675681

676682
if chunk_store is not None:
677-
warnings.warn("chunk_store is not yet implemented", RuntimeWarning, stacklevel=2)
683+
warnings.warn("chunk_store is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
678684
if cache_attrs is not None:
679-
warnings.warn("cache_attrs is not yet implemented", RuntimeWarning, stacklevel=2)
685+
warnings.warn("cache_attrs is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
680686
if synchronizer is not None:
681-
warnings.warn("synchronizer is not yet implemented", RuntimeWarning, stacklevel=2)
687+
warnings.warn("synchronizer is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
682688
if meta_array is not None:
683-
warnings.warn("meta_array is not yet implemented", RuntimeWarning, stacklevel=2)
689+
warnings.warn("meta_array is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
684690

685691
if attributes is None:
686692
attributes = {}
@@ -827,13 +833,13 @@ async def open_group(
827833
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
828834

829835
if cache_attrs is not None:
830-
warnings.warn("cache_attrs is not yet implemented", RuntimeWarning, stacklevel=2)
836+
warnings.warn("cache_attrs is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
831837
if synchronizer is not None:
832-
warnings.warn("synchronizer is not yet implemented", RuntimeWarning, stacklevel=2)
838+
warnings.warn("synchronizer is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
833839
if meta_array is not None:
834-
warnings.warn("meta_array is not yet implemented", RuntimeWarning, stacklevel=2)
840+
warnings.warn("meta_array is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
835841
if chunk_store is not None:
836-
warnings.warn("chunk_store is not yet implemented", RuntimeWarning, stacklevel=2)
842+
warnings.warn("chunk_store is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
837843

838844
store_path = await make_store_path(store, mode=mode, storage_options=storage_options, path=path)
839845
if attributes is None:
@@ -1011,19 +1017,19 @@ async def create(
10111017
)
10121018

10131019
if synchronizer is not None:
1014-
warnings.warn("synchronizer is not yet implemented", RuntimeWarning, stacklevel=2)
1020+
warnings.warn("synchronizer is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
10151021
if chunk_store is not None:
1016-
warnings.warn("chunk_store is not yet implemented", RuntimeWarning, stacklevel=2)
1022+
warnings.warn("chunk_store is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
10171023
if cache_metadata is not None:
1018-
warnings.warn("cache_metadata is not yet implemented", RuntimeWarning, stacklevel=2)
1024+
warnings.warn("cache_metadata is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
10191025
if cache_attrs is not None:
1020-
warnings.warn("cache_attrs is not yet implemented", RuntimeWarning, stacklevel=2)
1026+
warnings.warn("cache_attrs is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
10211027
if object_codec is not None:
1022-
warnings.warn("object_codec is not yet implemented", RuntimeWarning, stacklevel=2)
1028+
warnings.warn("object_codec is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
10231029
if read_only is not None:
1024-
warnings.warn("read_only is not yet implemented", RuntimeWarning, stacklevel=2)
1030+
warnings.warn("read_only is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
10251031
if meta_array is not None:
1026-
warnings.warn("meta_array is not yet implemented", RuntimeWarning, stacklevel=2)
1032+
warnings.warn("meta_array is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
10271033

10281034
if write_empty_chunks is not None:
10291035
_warn_write_empty_chunks_kwarg()
@@ -1042,7 +1048,7 @@ async def create(
10421048
"This is redundant. When both are set, write_empty_chunks will be used instead "
10431049
"of the value in config."
10441050
)
1045-
warnings.warn(UserWarning(msg), stacklevel=1)
1051+
warnings.warn(ZarrUserWarning(msg), stacklevel=1)
10461052
config_parsed = dataclasses.replace(config_parsed, write_empty_chunks=write_empty_chunks)
10471053

10481054
return await AsyncArray._create(

src/zarr/api/synchronous.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from zarr.core.group import Group
1111
from zarr.core.sync import sync
1212
from zarr.core.sync_group import create_hierarchy
13+
from zarr.errors import ZarrDeprecationWarning
1314

1415
if TYPE_CHECKING:
1516
from collections.abc import Iterable
@@ -339,7 +340,7 @@ def save_group(
339340
)
340341

341342

342-
@deprecated("Use Group.tree instead.")
343+
@deprecated("Use Group.tree instead.", category=ZarrDeprecationWarning)
343344
def tree(grp: Group, expand: bool | None = None, level: int | None = None) -> Any:
344345
"""Provide a rich display of the hierarchy.
345346

0 commit comments

Comments
 (0)