Skip to content

Commit 63e95c8

Browse files
committed
numpydoc error
1 parent 92bcbf9 commit 63e95c8

File tree

1 file changed

+41
-29
lines changed

1 file changed

+41
-29
lines changed

src/zarr/core/group.py

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,43 +1165,40 @@ async def create_dataset(
11651165
await array.setitem(slice(None), data)
11661166
return array
11671167

1168-
@deprecated("Use AsyncGroup.require_array instead.")
1169-
async def require_dataset(
1168+
@deprecated("Use Group.require_array instead.")
1169+
def require_dataset(
11701170
self,
11711171
name: str,
11721172
*,
1173-
shape: ChunkCoords,
1173+
shape: ShapeLike,
11741174
dtype: npt.DTypeLike = None,
11751175
exact: bool = False,
11761176
**kwargs: Any,
11771177
) -> AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]:
11781178
"""Obtain an array, creating if it doesn't exist.
11791179
11801180
.. 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.
11821182
11831183
Arrays are known as "datasets" in HDF5 terminology. For compatibility
11841184
with h5py, Zarr groups also implement the :func:`zarr.AsyncGroup.create_dataset` method.
11851185
1186-
Other `kwargs` are as per :func:`zarr.AsyncGroup.create_dataset`.
1186+
Other `kwargs` are as per :func:`zarr.AsyncGroup.create_array`.
11871187
11881188
Parameters
11891189
----------
11901190
name : str
11911191
Array name.
11921192
shape : int or tuple of ints
11931193
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`.
11991196
12001197
Returns
12011198
-------
12021199
a : AsyncArray
12031200
"""
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)
12051202

12061203
async def require_array(
12071204
self,
@@ -1214,7 +1211,7 @@ async def require_array(
12141211
) -> AsyncArray[ArrayV2Metadata] | AsyncArray[ArrayV3Metadata]:
12151212
"""Obtain an array, creating if it doesn't exist.
12161213
1217-
Other `kwargs` are as per :func:`zarr.AsyncGroup.create_dataset`.
1214+
Other `kwargs` are as per :func:`zarr.AsyncGroup.create_array`.
12181215
12191216
Parameters
12201217
----------
@@ -1223,9 +1220,9 @@ async def require_array(
12231220
shape : int or tuple of ints
12241221
Array shape.
12251222
dtype : str or dtype, optional
1226-
NumPy dtype.
1223+
NumPy dtype. If None, the dtype will be inferred from the existing array.
12271224
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
12291226
`dtype` can be cast from array dtype.
12301227
12311228
Returns
@@ -2514,34 +2511,41 @@ def create_dataset(self, name: str, **kwargs: Any) -> Array:
25142511
.. deprecated:: 3.0.0
25152512
The h5py compatibility methods will be removed in 3.1.0. Use `Group.create_array` instead.
25162513
2517-
25182514
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.
25202516
25212517
Parameters
25222518
----------
25232519
name : str
25242520
Array name.
25252521
**kwargs : dict
2526-
Additional arguments passed to :func:`zarr.Group.create_array`
2522+
Additional arguments passed to :func:`zarr.AsyncGroup.create_array`.
25272523
25282524
Returns
25292525
-------
2530-
a : Array
2526+
a : AsyncArray
25312527
"""
25322528
return Array(self._sync(self._async_group.create_dataset(name, **kwargs)))
25332529

25342530
@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]:
25362540
"""Obtain an array, creating if it doesn't exist.
25372541
25382542
.. deprecated:: 3.0.0
25392543
The h5py compatibility methods will be removed in 3.1.0. Use `Group.require_array` instead.
25402544
25412545
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.
25432547
2544-
Other `kwargs` are as per :func:`zarr.Group.create_dataset`.
2548+
Other `kwargs` are as per :func:`zarr.AsyncGroup.create_array`.
25452549
25462550
Parameters
25472551
----------
@@ -2559,12 +2563,20 @@ def require_dataset(self, name: str, *, shape: ShapeLike, **kwargs: Any) -> Arra
25592563
-------
25602564
a : AsyncArray
25612565
"""
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)
25632567

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:
25652577
"""Obtain an array, creating if it doesn't exist.
25662578
2567-
Other `kwargs` are as per :func:`zarr.Group.create_array`.
2579+
Other `kwargs` are as per :func:`zarr.AsyncGroup.create_array`.
25682580
25692581
Parameters
25702582
----------
@@ -2573,16 +2585,16 @@ def require_array(self, name: str, *, shape: ShapeLike, **kwargs: Any) -> Array:
25732585
shape : int or tuple of ints
25742586
Array shape.
25752587
dtype : str or dtype, optional
2576-
NumPy dtype.
2588+
NumPy dtype. If None, the dtype will be inferred from the existing array.
25772589
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
25792591
`dtype` can be cast from array dtype.
25802592
25812593
Returns
25822594
-------
2583-
a : AsyncArray
2595+
a : Array
25842596
"""
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)))
25862598

25872599
@_deprecate_positional_args
25882600
def empty(self, *, name: str, shape: ChunkCoords, **kwargs: Any) -> Array:
@@ -2931,7 +2943,7 @@ async def create_hierarchy(
29312943
This function will parse its input to ensure that the hierarchy is complete. Any implicit groups
29322944
will be inserted as needed. For example, an input like
29332945
```{'a/b': GroupMetadata}``` will be parsed to
2934-
```{'': GroupMetadata, 'a': GroupMetadata, 'b': Groupmetadata}```
2946+
```{'': GroupMetadata, 'a': GroupMetadata, 'b': Groupmetadata}```.
29352947
29362948
After input parsing, this function then creates all the nodes in the hierarchy concurrently.
29372949

0 commit comments

Comments
 (0)