Skip to content

Commit 07f07ea

Browse files
committed
use create_array everywhere in group class
1 parent af55ac4 commit 07f07ea

File tree

3 files changed

+130
-187
lines changed

3 files changed

+130
-187
lines changed

src/zarr/core/array.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
NDBuffer,
2727
default_buffer_prototype,
2828
)
29-
from zarr.core.chunk_grids import RegularChunkGrid, _auto_partition, normalize_chunks
29+
from zarr.core.chunk_grids import RegularChunkGrid, normalize_chunks
3030
from zarr.core.chunk_key_encodings import (
3131
ChunkKeyEncoding,
3232
DefaultChunkKeyEncoding,
@@ -3478,7 +3478,7 @@ async def create_array(
34783478
storage_options: dict[str, Any] | None = None,
34793479
overwrite: bool = False,
34803480
config: ArrayConfig | ArrayConfigParams | None = None,
3481-
data: np.ndarray | None = None,
3481+
data: npt.ArrayLike | None = None,
34823482
) -> AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]:
34833483
"""Create an array.
34843484
@@ -3580,20 +3580,17 @@ async def create_array(
35803580
config=config_parsed,
35813581
)
35823582
else:
3583-
shard_shape_parsed, chunk_shape_parsed = _auto_partition(
3584-
shape, dtype, shard_shape, chunk_shape
3585-
)
3586-
if shard_shape_parsed is not None:
3587-
sharding_codec = ShardingCodec(chunk_shape=chunk_shape_parsed, codecs=sub_codecs)
3583+
if shard_shape is not None:
3584+
sharding_codec = ShardingCodec(chunk_shape=chunk_shape, codecs=sub_codecs)
35883585
sharding_codec.validate(
3589-
shape=chunk_shape_parsed,
3586+
shape=chunk_shape,
35903587
dtype=dtype,
3591-
chunk_grid=RegularChunkGrid(chunk_shape=shard_shape_parsed),
3588+
chunk_grid=RegularChunkGrid(chunk_shape=shard_shape),
35923589
)
35933590
codecs = (sharding_codec,)
3594-
chunks_out = shard_shape_parsed
3591+
chunks_out = shard_shape
35953592
else:
3596-
chunks_out = chunk_shape_parsed
3593+
chunks_out = chunk_shape
35973594
codecs = sub_codecs
35983595

35993596
result = await AsyncArray._create_v3(

src/zarr/core/chunk_grids.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from abc import abstractmethod
88
from dataclasses import dataclass
99
from functools import reduce
10-
from typing import TYPE_CHECKING, Any, Literal
10+
from typing import TYPE_CHECKING, Any
1111

1212
import numpy as np
1313

@@ -26,8 +26,6 @@
2626
from collections.abc import Iterator
2727
from typing import Self
2828

29-
import numpy.typing as npt
30-
3129

3230
def _guess_chunks(
3331
shape: ShapeLike,

0 commit comments

Comments
 (0)