37
37
GroupMetadata ,
38
38
create_hierarchy ,
39
39
)
40
- from zarr .core .metadata import ArrayMetadataDict , ArrayV2Metadata , ArrayV3Metadata
40
+ from zarr .core .metadata import ArrayMetadataDict , ArrayV2Metadata
41
41
from zarr .errors import (
42
42
ArrayNotFoundError ,
43
43
GroupNotFoundError ,
57
57
from zarr .core .buffer import NDArrayLikeOrScalar
58
58
from zarr .core .chunk_key_encodings import ChunkKeyEncoding
59
59
from zarr .storage import StoreLike
60
- from zarr .types import AnyArray
60
+ from zarr .types import AnyArray , AnyAsyncArray
61
61
62
62
# TODO: this type could use some more thought
63
- ArrayLike : TypeAlias = (
64
- AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ] | AnyArray | npt .NDArray [Any ]
65
- )
63
+ ArrayLike : TypeAlias = AnyAsyncArray | AnyArray | npt .NDArray [Any ]
66
64
PathLike = str
67
65
68
66
__all__ = [
@@ -314,7 +312,7 @@ async def open(
314
312
path : str | None = None ,
315
313
storage_options : dict [str , Any ] | None = None ,
316
314
** kwargs : Any , # TODO: type kwargs as valid args to open_array
317
- ) -> AsyncArray [ ArrayV2Metadata ] | AsyncArray [ ArrayV3Metadata ] | AsyncGroup :
315
+ ) -> AnyAsyncArray | AsyncGroup :
318
316
"""Convenience function to open a group or array using file-mode-like semantics.
319
317
320
318
Parameters
@@ -571,9 +569,7 @@ async def tree(grp: AsyncGroup, expand: bool | None = None, level: int | None =
571
569
return await grp .tree (expand = expand , level = level )
572
570
573
571
574
- async def array (
575
- data : npt .ArrayLike | AnyArray , ** kwargs : Any
576
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
572
+ async def array (data : npt .ArrayLike | AnyArray , ** kwargs : Any ) -> AnyAsyncArray :
577
573
"""Create an array filled with `data`.
578
574
579
575
Parameters
@@ -906,7 +902,7 @@ async def create(
906
902
storage_options : dict [str , Any ] | None = None ,
907
903
config : ArrayConfigLike | None = None ,
908
904
** kwargs : Any ,
909
- ) -> AsyncArray [ ArrayV2Metadata ] | AsyncArray [ ArrayV3Metadata ] :
905
+ ) -> AnyAsyncArray :
910
906
"""Create an array.
911
907
912
908
Parameters
@@ -1078,9 +1074,7 @@ async def create(
1078
1074
)
1079
1075
1080
1076
1081
- async def empty (
1082
- shape : tuple [int , ...], ** kwargs : Any
1083
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1077
+ async def empty (shape : tuple [int , ...], ** kwargs : Any ) -> AnyAsyncArray :
1084
1078
"""Create an empty array with the specified shape. The contents will be filled with the
1085
1079
array's fill value or zeros if no fill value is provided.
1086
1080
@@ -1101,9 +1095,7 @@ async def empty(
1101
1095
return await create (shape = shape , fill_value = None , ** kwargs )
1102
1096
1103
1097
1104
- async def empty_like (
1105
- a : ArrayLike , ** kwargs : Any
1106
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1098
+ async def empty_like (a : ArrayLike , ** kwargs : Any ) -> AnyAsyncArray :
1107
1099
"""Create an empty array like `a`. The contents will be filled with the
1108
1100
array's fill value or zeros if no fill value is provided.
1109
1101
@@ -1130,9 +1122,7 @@ async def empty_like(
1130
1122
1131
1123
1132
1124
# TODO: add type annotations for fill_value and kwargs
1133
- async def full (
1134
- shape : tuple [int , ...], fill_value : Any , ** kwargs : Any
1135
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1125
+ async def full (shape : tuple [int , ...], fill_value : Any , ** kwargs : Any ) -> AnyAsyncArray :
1136
1126
"""Create an array, with `fill_value` being used as the default value for
1137
1127
uninitialized portions of the array.
1138
1128
@@ -1154,9 +1144,7 @@ async def full(
1154
1144
1155
1145
1156
1146
# TODO: add type annotations for kwargs
1157
- async def full_like (
1158
- a : ArrayLike , ** kwargs : Any
1159
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1147
+ async def full_like (a : ArrayLike , ** kwargs : Any ) -> AnyAsyncArray :
1160
1148
"""Create a filled array like `a`.
1161
1149
1162
1150
Parameters
@@ -1177,9 +1165,7 @@ async def full_like(
1177
1165
return await full (** like_kwargs )
1178
1166
1179
1167
1180
- async def ones (
1181
- shape : tuple [int , ...], ** kwargs : Any
1182
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1168
+ async def ones (shape : tuple [int , ...], ** kwargs : Any ) -> AnyAsyncArray :
1183
1169
"""Create an array, with one being used as the default value for
1184
1170
uninitialized portions of the array.
1185
1171
@@ -1198,9 +1184,7 @@ async def ones(
1198
1184
return await create (shape = shape , fill_value = 1 , ** kwargs )
1199
1185
1200
1186
1201
- async def ones_like (
1202
- a : ArrayLike , ** kwargs : Any
1203
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1187
+ async def ones_like (a : ArrayLike , ** kwargs : Any ) -> AnyAsyncArray :
1204
1188
"""Create an array of ones like `a`.
1205
1189
1206
1190
Parameters
@@ -1227,7 +1211,7 @@ async def open_array(
1227
1211
path : PathLike = "" ,
1228
1212
storage_options : dict [str , Any ] | None = None ,
1229
1213
** kwargs : Any , # TODO: type kwargs as valid args to save
1230
- ) -> AsyncArray [ ArrayV2Metadata ] | AsyncArray [ ArrayV3Metadata ] :
1214
+ ) -> AnyAsyncArray :
1231
1215
"""Open an array using file-mode-like semantics.
1232
1216
1233
1217
Parameters
@@ -1276,9 +1260,7 @@ async def open_array(
1276
1260
raise ArrayNotFoundError (msg ) from err
1277
1261
1278
1262
1279
- async def open_like (
1280
- a : ArrayLike , path : str , ** kwargs : Any
1281
- ) -> AsyncArray [ArrayV3Metadata ] | AsyncArray [ArrayV2Metadata ]:
1263
+ async def open_like (a : ArrayLike , path : str , ** kwargs : Any ) -> AnyAsyncArray :
1282
1264
"""Open a persistent array like `a`.
1283
1265
1284
1266
Parameters
@@ -1301,9 +1283,7 @@ async def open_like(
1301
1283
return await open_array (path = path , ** like_kwargs )
1302
1284
1303
1285
1304
- async def zeros (
1305
- shape : tuple [int , ...], ** kwargs : Any
1306
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1286
+ async def zeros (shape : tuple [int , ...], ** kwargs : Any ) -> AnyAsyncArray :
1307
1287
"""Create an array, with zero being used as the default value for
1308
1288
uninitialized portions of the array.
1309
1289
@@ -1322,9 +1302,7 @@ async def zeros(
1322
1302
return await create (shape = shape , fill_value = 0 , ** kwargs )
1323
1303
1324
1304
1325
- async def zeros_like (
1326
- a : ArrayLike , ** kwargs : Any
1327
- ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1305
+ async def zeros_like (a : ArrayLike , ** kwargs : Any ) -> AnyAsyncArray :
1328
1306
"""Create an array of zeros like `a`.
1329
1307
1330
1308
Parameters
0 commit comments