38
38
GroupMetadata ,
39
39
create_hierarchy ,
40
40
)
41
- from zarr .core .metadata import ArrayMetadataDict , ArrayV2Metadata , ArrayV3Metadata
41
+ from zarr .core .metadata import ArrayMetadataDict , ArrayV2Metadata
42
42
from zarr .errors import (
43
43
GroupNotFoundError ,
44
44
NodeTypeValidationError ,
58
58
from zarr .core .buffer import NDArrayLikeOrScalar
59
59
from zarr .core .chunk_key_encodings import ChunkKeyEncoding
60
60
from zarr .storage import StoreLike
61
- from zarr .types import AnyArray
61
+ from zarr .types import AnyArray , AnyAsyncArray
62
62
63
63
# TODO: this type could use some more thought
64
- ArrayLike : TypeAlias = (
65
- AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ] | AnyArray | npt .NDArray [Any ]
66
- )
64
+ ArrayLike : TypeAlias = AnyAsyncArray | AnyArray | npt .NDArray [Any ]
67
65
PathLike = str
68
66
69
67
__all__ = [
@@ -315,7 +313,7 @@ async def open(
315
313
path : str | None = None ,
316
314
storage_options : dict [str , Any ] | None = None ,
317
315
** kwargs : Any , # TODO: type kwargs as valid args to open_array
318
- ) -> AsyncArray [ ArrayV2Metadata ] | AsyncArray [ ArrayV3Metadata ] | AsyncGroup :
316
+ ) -> AnyAsyncArray | AsyncGroup :
319
317
"""Convenience function to open a group or array using file-mode-like semantics.
320
318
321
319
Parameters
@@ -570,9 +568,7 @@ async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None =
570
568
return await grp .tree (expand = expand , level = level )
571
569
572
570
573
- async def array (
574
- data : npt .ArrayLike | AnyArray , ** kwargs : Any
575
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
571
+ async def array (data : npt .ArrayLike | AnyArray , ** kwargs : Any ) -> AnyAsyncArray :
576
572
"""Create an array filled with `data`.
577
573
578
574
Parameters
@@ -904,7 +900,7 @@ async def create(
904
900
storage_options : dict [str , Any ] | None = None ,
905
901
config : ArrayConfigLike | None = None ,
906
902
** kwargs : Any ,
907
- ) -> AsyncArray [ ArrayV2Metadata ] | AsyncArray [ ArrayV3Metadata ] :
903
+ ) -> AnyAsyncArray :
908
904
"""Create an array.
909
905
910
906
Parameters
@@ -1076,9 +1072,7 @@ async def create(
1076
1072
)
1077
1073
1078
1074
1079
- async def empty (
1080
- shape : ChunkCoords , ** kwargs : Any
1081
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1075
+ async def empty (shape : ChunkCoords , ** kwargs : Any ) -> AnyAsyncArray :
1082
1076
"""Create an empty array with the specified shape. The contents will be filled with the
1083
1077
array's fill value or zeros if no fill value is provided.
1084
1078
@@ -1099,9 +1093,7 @@ async def empty(
1099
1093
return await create (shape = shape , fill_value = None , ** kwargs )
1100
1094
1101
1095
1102
- async def empty_like (
1103
- a : ArrayLike , ** kwargs : Any
1104
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1096
+ async def empty_like (a : ArrayLike , ** kwargs : Any ) -> AnyAsyncArray :
1105
1097
"""Create an empty array like `a`. The contents will be filled with the
1106
1098
array's fill value or zeros if no fill value is provided.
1107
1099
@@ -1128,9 +1120,7 @@ async def empty_like(
1128
1120
1129
1121
1130
1122
# TODO: add type annotations for fill_value and kwargs
1131
- async def full (
1132
- shape : ChunkCoords , fill_value : Any , ** kwargs : Any
1133
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1123
+ async def full (shape : ChunkCoords , fill_value : Any , ** kwargs : Any ) -> AnyAsyncArray :
1134
1124
"""Create an array, with `fill_value` being used as the default value for
1135
1125
uninitialized portions of the array.
1136
1126
@@ -1152,9 +1142,7 @@ async def full(
1152
1142
1153
1143
1154
1144
# TODO: add type annotations for kwargs
1155
- async def full_like (
1156
- a : ArrayLike , ** kwargs : Any
1157
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1145
+ async def full_like (a : ArrayLike , ** kwargs : Any ) -> AnyAsyncArray :
1158
1146
"""Create a filled array like `a`.
1159
1147
1160
1148
Parameters
@@ -1175,9 +1163,7 @@ async def full_like(
1175
1163
return await full (** like_kwargs )
1176
1164
1177
1165
1178
- async def ones (
1179
- shape : ChunkCoords , ** kwargs : Any
1180
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1166
+ async def ones (shape : ChunkCoords , ** kwargs : Any ) -> AnyAsyncArray :
1181
1167
"""Create an array, with one being used as the default value for
1182
1168
uninitialized portions of the array.
1183
1169
@@ -1196,9 +1182,7 @@ async def ones(
1196
1182
return await create (shape = shape , fill_value = 1 , ** kwargs )
1197
1183
1198
1184
1199
- async def ones_like (
1200
- a : ArrayLike , ** kwargs : Any
1201
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1185
+ async def ones_like (a : ArrayLike , ** kwargs : Any ) -> AnyAsyncArray :
1202
1186
"""Create an array of ones like `a`.
1203
1187
1204
1188
Parameters
@@ -1225,7 +1209,7 @@ async def open_array(
1225
1209
path : PathLike = "" ,
1226
1210
storage_options : dict [str , Any ] | None = None ,
1227
1211
** kwargs : Any , # TODO: type kwargs as valid args to save
1228
- ) -> AsyncArray [ ArrayV2Metadata ] | AsyncArray [ ArrayV3Metadata ] :
1212
+ ) -> AnyAsyncArray :
1229
1213
"""Open an array using file-mode-like semantics.
1230
1214
1231
1215
Parameters
@@ -1273,9 +1257,7 @@ async def open_array(
1273
1257
raise
1274
1258
1275
1259
1276
- async def open_like (
1277
- a : ArrayLike , path : str , ** kwargs : Any
1278
- ) -> AsyncArray [ArrayV3Metadata ] | AsyncArray [ArrayV2Metadata ]:
1260
+ async def open_like (a : ArrayLike , path : str , ** kwargs : Any ) -> AnyAsyncArray :
1279
1261
"""Open a persistent array like `a`.
1280
1262
1281
1263
Parameters
@@ -1298,9 +1280,7 @@ async def open_like(
1298
1280
return await open_array (path = path , ** like_kwargs )
1299
1281
1300
1282
1301
- async def zeros (
1302
- shape : ChunkCoords , ** kwargs : Any
1303
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1283
+ async def zeros (shape : ChunkCoords , ** kwargs : Any ) -> AnyAsyncArray :
1304
1284
"""Create an array, with zero being used as the default value for
1305
1285
uninitialized portions of the array.
1306
1286
@@ -1319,9 +1299,7 @@ async def zeros(
1319
1299
return await create (shape = shape , fill_value = 0 , ** kwargs )
1320
1300
1321
1301
1322
- async def zeros_like (
1323
- a : ArrayLike , ** kwargs : Any
1324
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1302
+ async def zeros_like (a : ArrayLike , ** kwargs : Any ) -> AnyAsyncArray :
1325
1303
"""Create an array of zeros like `a`.
1326
1304
1327
1305
Parameters
0 commit comments