Skip to content

Commit d443965

Browse files
committed
Push filter parsing down the stack
1 parent 35176d5 commit d443965

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/zarr/api/asynchronous.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
_default_zarr_format,
3030
_warn_order_kwarg,
3131
_warn_write_empty_chunks_kwarg,
32-
parse_dtype,
3332
)
3433
from zarr.core.group import (
3534
AsyncGroup,
@@ -38,13 +37,14 @@
3837
create_hierarchy,
3938
)
4039
from zarr.core.metadata import ArrayMetadataDict, ArrayV2Metadata, ArrayV3Metadata
41-
from zarr.core.metadata.v2 import _default_compressor, _default_filters
4240
from zarr.errors import GroupNotFoundError, NodeTypeValidationError
4341
from zarr.storage._common import make_store_path
4442

4543
if TYPE_CHECKING:
4644
from collections.abc import Iterable
4745

46+
import numcodecs.abc
47+
4848
from zarr.abc.codec import Codec
4949
from zarr.core.buffer import NDArrayLikeOrScalar
5050
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
@@ -852,7 +852,7 @@ async def create(
852852
overwrite: bool = False,
853853
path: PathLike | None = None,
854854
chunk_store: StoreLike | None = None,
855-
filters: list[dict[str, JSON]] | None = None, # TODO: type has changed
855+
filters: Iterable[dict[str, JSON] | numcodecs.abc.Codec] | None = None,
856856
cache_metadata: bool | None = None,
857857
cache_attrs: bool | None = None,
858858
read_only: bool | None = None,
@@ -991,11 +991,6 @@ async def create(
991991
or _default_zarr_format()
992992
)
993993

994-
if zarr_format == 2:
995-
dtype = parse_dtype(dtype, zarr_format)
996-
if not filters:
997-
filters = _default_filters(dtype)
998-
999994
if synchronizer is not None:
1000995
warnings.warn("synchronizer is not yet implemented", RuntimeWarning, stacklevel=2)
1001996
if chunk_store is not None:

src/zarr/core/array.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ async def _create(
561561
chunks: ShapeLike | None = None,
562562
dimension_separator: Literal[".", "/"] | None = None,
563563
order: MemoryOrder | None = None,
564-
filters: list[dict[str, JSON]] | None = None,
564+
filters: Iterable[dict[str, JSON] | numcodecs.abc.Codec] | None = None,
565565
compressor: CompressorLike = "auto",
566566
# runtime
567567
overwrite: bool = False,
@@ -816,6 +816,9 @@ async def _create_v2(
816816
else:
817817
compressor_parsed = compressor
818818

819+
if filters is None:
820+
filters = _default_filters(dtype)
821+
819822
metadata = cls._create_metadata_v2(
820823
shape=shape,
821824
dtype=dtype,

0 commit comments

Comments
 (0)