Skip to content

Commit e223384

Browse files
committed
Push filter parsing down the stack
1 parent a6d3f45 commit e223384

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/zarr/api/asynchronous.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
if TYPE_CHECKING:
4848
from collections.abc import Iterable
4949

50+
import numcodecs.abc
51+
5052
from zarr.abc.codec import Codec
5153
from zarr.core.buffer import NDArrayLikeOrScalar
5254
from zarr.core.chunk_key_encodings import ChunkKeyEncoding
@@ -870,7 +872,7 @@ async def create(
870872
overwrite: bool = False,
871873
path: PathLike | None = None,
872874
chunk_store: StoreLike | None = None,
873-
filters: list[dict[str, JSON]] | None = None, # TODO: type has changed
875+
filters: Iterable[dict[str, JSON] | numcodecs.abc.Codec] | None = None,
874876
cache_metadata: bool | None = None,
875877
cache_attrs: bool | None = None,
876878
read_only: bool | None = None,
@@ -1008,11 +1010,6 @@ async def create(
10081010
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
10091011
or _default_zarr_format()
10101012
)
1011-
zdtype = parse_data_type(dtype, zarr_format=zarr_format)
1012-
if zarr_format == 2:
1013-
default_filters, default_compressor = _get_default_chunk_encoding_v2(zdtype)
1014-
if not filters:
1015-
filters = default_filters # type: ignore[assignment]
10161013

10171014
if synchronizer is not None:
10181015
warnings.warn("synchronizer is not yet implemented", RuntimeWarning, stacklevel=2)
@@ -1064,7 +1061,7 @@ async def create(
10641061
store_path,
10651062
shape=shape,
10661063
chunks=chunks,
1067-
dtype=zdtype,
1064+
dtype=dtype,
10681065
compressor=compressor,
10691066
fill_value=fill_value,
10701067
overwrite=overwrite,

src/zarr/core/array.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ async def _create(
568568
chunks: ShapeLike | None = None,
569569
dimension_separator: Literal[".", "/"] | None = None,
570570
order: MemoryOrder | None = None,
571-
filters: list[dict[str, JSON]] | None = None,
571+
filters: Iterable[dict[str, JSON] | numcodecs.abc.Codec] | None = None,
572572
compressor: CompressorLike = "auto",
573573
# runtime
574574
overwrite: bool = False,
@@ -831,6 +831,9 @@ async def _create_v2(
831831
else:
832832
compressor_parsed = compressor
833833

834+
if filters is None:
835+
filters = _default_filters(dtype)
836+
834837
metadata = cls._create_metadata_v2(
835838
shape=shape,
836839
dtype=dtype,

0 commit comments

Comments
 (0)