@@ -1165,43 +1165,40 @@ async def create_dataset(
1165
1165
await array .setitem (slice (None ), data )
1166
1166
return array
1167
1167
1168
- @deprecated ("Use AsyncGroup .require_array instead." )
1169
- async def require_dataset (
1168
+ @deprecated ("Use Group .require_array instead." )
1169
+ def require_dataset (
1170
1170
self ,
1171
1171
name : str ,
1172
1172
* ,
1173
- shape : ChunkCoords ,
1173
+ shape : ShapeLike ,
1174
1174
dtype : npt .DTypeLike = None ,
1175
1175
exact : bool = False ,
1176
1176
** kwargs : Any ,
1177
1177
) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1178
1178
"""Obtain an array, creating if it doesn't exist.
1179
1179
1180
1180
.. deprecated:: 3.0.0
1181
- The h5py compatibility methods will be removed in 3.1.0. Use `AsyncGroup.require_dataset ` instead.
1181
+ The h5py compatibility methods will be removed in 3.1.0. Use `Group.require_array ` instead.
1182
1182
1183
1183
Arrays are known as "datasets" in HDF5 terminology. For compatibility
1184
1184
with h5py, Zarr groups also implement the :func:`zarr.AsyncGroup.create_dataset` method.
1185
1185
1186
- Other `kwargs` are as per :func:`zarr.AsyncGroup.create_dataset `.
1186
+ Other `kwargs` are as per :func:`zarr.AsyncGroup.create_array `.
1187
1187
1188
1188
Parameters
1189
1189
----------
1190
1190
name : str
1191
1191
Array name.
1192
1192
shape : int or tuple of ints
1193
1193
Array shape.
1194
- dtype : str or dtype, optional
1195
- NumPy dtype.
1196
- exact : bool, optional
1197
- If True, require `dtype` to match exactly. If false, require
1198
- `dtype` can be cast from array dtype.
1194
+ **kwargs
1195
+ Additional keyword arguments passed to :func:`zarr.AsyncGroup.create_array`.
1199
1196
1200
1197
Returns
1201
1198
-------
1202
1199
a : AsyncArray
1203
1200
"""
1204
- return await self .require_array (name , shape = shape , dtype = dtype , exact = exact , ** kwargs )
1201
+ return self .require_array (name , shape = shape , dtype = dtype , exact = exact , ** kwargs )
1205
1202
1206
1203
async def require_array (
1207
1204
self ,
@@ -1214,7 +1211,7 @@ async def require_array(
1214
1211
) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
1215
1212
"""Obtain an array, creating if it doesn't exist.
1216
1213
1217
- Other `kwargs` are as per :func:`zarr.AsyncGroup.create_dataset `.
1214
+ Other `kwargs` are as per :func:`zarr.AsyncGroup.create_array `.
1218
1215
1219
1216
Parameters
1220
1217
----------
@@ -1223,9 +1220,9 @@ async def require_array(
1223
1220
shape : int or tuple of ints
1224
1221
Array shape.
1225
1222
dtype : str or dtype, optional
1226
- NumPy dtype.
1223
+ NumPy dtype. If None, the dtype will be inferred from the existing array.
1227
1224
exact : bool, optional
1228
- If True, require `dtype` to match exactly. If false , require
1225
+ If True, require `dtype` to match exactly. If False , require
1229
1226
`dtype` can be cast from array dtype.
1230
1227
1231
1228
Returns
@@ -2514,34 +2511,41 @@ def create_dataset(self, name: str, **kwargs: Any) -> Array:
2514
2511
.. deprecated:: 3.0.0
2515
2512
The h5py compatibility methods will be removed in 3.1.0. Use `Group.create_array` instead.
2516
2513
2517
-
2518
2514
Arrays are known as "datasets" in HDF5 terminology. For compatibility
2519
- with h5py, Zarr groups also implement the :func:`zarr.Group .require_dataset` method.
2515
+ with h5py, Zarr groups also implement the :func:`zarr.AsyncGroup .require_dataset` method.
2520
2516
2521
2517
Parameters
2522
2518
----------
2523
2519
name : str
2524
2520
Array name.
2525
2521
**kwargs : dict
2526
- Additional arguments passed to :func:`zarr.Group .create_array`
2522
+ Additional arguments passed to :func:`zarr.AsyncGroup .create_array`.
2527
2523
2528
2524
Returns
2529
2525
-------
2530
- a : Array
2526
+ a : AsyncArray
2531
2527
"""
2532
2528
return Array (self ._sync (self ._async_group .create_dataset (name , ** kwargs )))
2533
2529
2534
2530
@deprecated ("Use Group.require_array instead." )
2535
- def require_dataset (self , name : str , * , shape : ShapeLike , ** kwargs : Any ) -> Array :
2531
+ def require_dataset (
2532
+ self ,
2533
+ name : str ,
2534
+ * ,
2535
+ shape : ShapeLike ,
2536
+ dtype : npt .DTypeLike = None ,
2537
+ exact : bool = False ,
2538
+ ** kwargs : Any ,
2539
+ ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
2536
2540
"""Obtain an array, creating if it doesn't exist.
2537
2541
2538
2542
.. deprecated:: 3.0.0
2539
2543
The h5py compatibility methods will be removed in 3.1.0. Use `Group.require_array` instead.
2540
2544
2541
2545
Arrays are known as "datasets" in HDF5 terminology. For compatibility
2542
- with h5py, Zarr groups also implement the :func:`zarr.Group .create_dataset` method.
2546
+ with h5py, Zarr groups also implement the :func:`zarr.AsyncGroup .create_dataset` method.
2543
2547
2544
- Other `kwargs` are as per :func:`zarr.Group.create_dataset `.
2548
+ Other `kwargs` are as per :func:`zarr.AsyncGroup.create_array `.
2545
2549
2546
2550
Parameters
2547
2551
----------
@@ -2559,12 +2563,20 @@ def require_dataset(self, name: str, *, shape: ShapeLike, **kwargs: Any) -> Arra
2559
2563
-------
2560
2564
a : AsyncArray
2561
2565
"""
2562
- return Array ( self ._sync ( self . _async_group . require_array (name , shape = shape , ** kwargs )) )
2566
+ return self .require_array (name , shape = shape , dtype = dtype , exact = exact , ** kwargs )
2563
2567
2564
- def require_array (self , name : str , * , shape : ShapeLike , ** kwargs : Any ) -> Array :
2568
+ def require_array (
2569
+ self ,
2570
+ name : str ,
2571
+ * ,
2572
+ shape : ShapeLike ,
2573
+ dtype : npt .DTypeLike = None ,
2574
+ exact : bool = False ,
2575
+ ** kwargs : Any ,
2576
+ ) -> Array :
2565
2577
"""Obtain an array, creating if it doesn't exist.
2566
2578
2567
- Other `kwargs` are as per :func:`zarr.Group .create_array`.
2579
+ Other `kwargs` are as per :func:`zarr.AsyncGroup .create_array`.
2568
2580
2569
2581
Parameters
2570
2582
----------
@@ -2573,16 +2585,16 @@ def require_array(self, name: str, *, shape: ShapeLike, **kwargs: Any) -> Array:
2573
2585
shape : int or tuple of ints
2574
2586
Array shape.
2575
2587
dtype : str or dtype, optional
2576
- NumPy dtype.
2588
+ NumPy dtype. If None, the dtype will be inferred from the existing array.
2577
2589
exact : bool, optional
2578
- If True, require `dtype` to match exactly. If false , require
2590
+ If True, require `dtype` to match exactly. If False , require
2579
2591
`dtype` can be cast from array dtype.
2580
2592
2581
2593
Returns
2582
2594
-------
2583
- a : AsyncArray
2595
+ a : Array
2584
2596
"""
2585
- return Array (self ._sync (self ._async_group .require_array (name , shape = shape , ** kwargs )))
2597
+ return Array (self ._sync (self ._async_group .require_array (name , shape = shape , dtype = dtype , exact = exact , ** kwargs )))
2586
2598
2587
2599
@_deprecate_positional_args
2588
2600
def empty (self , * , name : str , shape : ChunkCoords , ** kwargs : Any ) -> Array :
@@ -2931,7 +2943,7 @@ async def create_hierarchy(
2931
2943
This function will parse its input to ensure that the hierarchy is complete. Any implicit groups
2932
2944
will be inserted as needed. For example, an input like
2933
2945
```{'a/b': GroupMetadata}``` will be parsed to
2934
- ```{'': GroupMetadata, 'a': GroupMetadata, 'b': Groupmetadata}```
2946
+ ```{'': GroupMetadata, 'a': GroupMetadata, 'b': Groupmetadata}```.
2935
2947
2936
2948
After input parsing, this function then creates all the nodes in the hierarchy concurrently.
2937
2949
0 commit comments