Skip to content

Commit 150d557

Browse files
committed
move defaults
1 parent db56a62 commit 150d557

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/zarr/core/array.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
ZARRAY_JSON,
3434
ZATTRS_JSON,
3535
ChunkCoords,
36+
MemoryOrder,
3637
ShapeLike,
3738
ZarrFormat,
3839
concurrent_map,
@@ -203,29 +204,29 @@ class AsyncArray(Generic[T_ArrayMetadata]):
203204
metadata: T_ArrayMetadata
204205
store_path: StorePath
205206
codec_pipeline: CodecPipeline = field(init=False)
206-
order: Literal["C", "F"]
207+
order: MemoryOrder
207208

208209
@overload
209210
def __init__(
210211
self: AsyncArray[ArrayV2Metadata],
211212
metadata: ArrayV2Metadata | ArrayV2MetadataDict,
212213
store_path: StorePath,
213-
order: Literal["C", "F"] | None = None,
214+
order: MemoryOrder | None = None,
214215
) -> None: ...
215216

216217
@overload
217218
def __init__(
218219
self: AsyncArray[ArrayV3Metadata],
219220
metadata: ArrayV3Metadata | ArrayV3MetadataDict,
220221
store_path: StorePath,
221-
order: Literal["C", "F"] | None = None,
222+
order: MemoryOrder | None = None,
222223
) -> None: ...
223224

224225
def __init__(
225226
self,
226227
metadata: ArrayMetadata | ArrayMetadataDict,
227228
store_path: StorePath,
228-
order: Literal["C", "F"] | None = None,
229+
order: MemoryOrder | None = None,
229230
) -> None:
230231
if isinstance(metadata, dict):
231232
zarr_format = metadata["zarr_format"]
@@ -261,7 +262,7 @@ async def create(
261262
attributes: dict[str, JSON] | None = None,
262263
chunks: ShapeLike | None = None,
263264
dimension_separator: Literal[".", "/"] | None = None,
264-
order: Literal["C", "F"] | None = None,
265+
order: MemoryOrder | None = None,
265266
filters: list[dict[str, JSON]] | None = None,
266267
compressor: dict[str, JSON] | None = None,
267268
# runtime
@@ -350,7 +351,7 @@ async def create(
350351
# v2 only
351352
chunks: ShapeLike | None = None,
352353
dimension_separator: Literal[".", "/"] | None = None,
353-
order: Literal["C", "F"] | None = None,
354+
order: MemoryOrder | None = None,
354355
filters: list[dict[str, JSON]] | None = None,
355356
compressor: dict[str, JSON] | None = None,
356357
# runtime
@@ -382,7 +383,7 @@ async def create(
382383
# v2 only
383384
chunks: ShapeLike | None = None,
384385
dimension_separator: Literal[".", "/"] | None = None,
385-
order: Literal["C", "F"] | None = None,
386+
order: MemoryOrder | None = None,
386387
filters: list[dict[str, JSON]] | None = None,
387388
compressor: dict[str, JSON] | None = None,
388389
# runtime
@@ -422,7 +423,6 @@ async def create(
422423
V2 only. V3 arrays cannot have a dimension separator.
423424
order : Literal["C", "F"], optional
424425
The order of the array (default is None).
425-
V2 only. V3 arrays should not have 'order' parameter.
426426
filters : list[dict[str, JSON]], optional
427427
The filters used to compress the data (default is None).
428428
V2 only. V3 arrays should not have 'filters' parameter.
@@ -542,7 +542,7 @@ async def _create_v3(
542542
dtype: npt.DTypeLike,
543543
chunk_shape: ChunkCoords,
544544
fill_value: Any | None = None,
545-
order: Literal["C", "F"] | None = None,
545+
order: MemoryOrder | None = None,
546546
chunk_key_encoding: (
547547
ChunkKeyEncoding
548548
| tuple[Literal["default"], Literal[".", "/"]]
@@ -600,16 +600,17 @@ async def _create_v2(
600600
chunks: ChunkCoords,
601601
dimension_separator: Literal[".", "/"] | None = None,
602602
fill_value: None | float = None,
603-
order: Literal["C", "F"] | None = None,
603+
order: MemoryOrder | None = None,
604604
filters: list[dict[str, JSON]] | None = None,
605605
compressor: dict[str, JSON] | None = None,
606606
attributes: dict[str, JSON] | None = None,
607607
exists_ok: bool = False,
608608
) -> AsyncArray[ArrayV2Metadata]:
609609
if not exists_ok:
610610
await ensure_no_existing_node(store_path, zarr_format=2)
611+
611612
if order is None:
612-
order = config.get("array.order", "C")
613+
order = parse_indexing_order(config.get("array.order"))
613614

614615
if dimension_separator is None:
615616
dimension_separator = "."
@@ -1177,7 +1178,7 @@ def create(
11771178
# v2 only
11781179
chunks: ChunkCoords | None = None,
11791180
dimension_separator: Literal[".", "/"] | None = None,
1180-
order: Literal["C", "F"] | None = None,
1181+
order: MemoryOrder | None = None,
11811182
filters: list[dict[str, JSON]] | None = None,
11821183
compressor: dict[str, JSON] | None = None,
11831184
# runtime
@@ -1368,7 +1369,7 @@ def store_path(self) -> StorePath:
13681369
return self._async_array.store_path
13691370

13701371
@property
1371-
def order(self) -> Literal["C", "F"]:
1372+
def order(self) -> MemoryOrder:
13721373
return self._async_array.order
13731374

13741375
@property

0 commit comments

Comments
 (0)