Skip to content
Prev Previous commit
Next Next commit
add deprecation warnings
  • Loading branch information
jhamman committed Sep 4, 2024
commit 3825d3f2cc690f6fc18ba4c7411ead2c1902b3e0
39 changes: 39 additions & 0 deletions src/zarr/core/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ async def create_array(
data=data,
)

@deprecated("Use Group.create_array instead.")
async def create_dataset(self, name: str, **kwargs: Any) -> AsyncArray:
"""Create an array.

Expand All @@ -467,9 +468,13 @@ async def create_dataset(self, name: str, **kwargs: Any) -> AsyncArray:
Returns
-------
a : AsyncArray

.. deprecated:: 3.0.0
The h5py compatibility methods will be removed in 3.1.0. Use `Group.create_array` instead.
"""
return await self.create_array(name, **kwargs)

@deprecated("Use Group.require_array instead.")
async def require_dataset(
self,
name: str,
Expand All @@ -486,6 +491,40 @@ async def require_dataset(

Other `kwargs` are as per :func:`zarr.AsyncGroup.create_dataset`.

Parameters
----------
name : string
Array name.
shape : int or tuple of ints
Array shape.
dtype : string or dtype, optional
NumPy dtype.
exact : bool, optional
If True, require `dtype` to match exactly. If false, require
`dtype` can be cast from array dtype.

Returns
-------
a : AsyncArray

.. deprecated:: 3.0.0
The h5py compatibility methods will be removed in 3.1.0. Use `Group.require_dataset` instead.
"""
return await self.require_array(name, shape=shape, dtype=dtype, exact=exact, **kwargs)

async def require_array(
self,
name: str,
*,
shape: ChunkCoords,
dtype: npt.DTypeLike = None,
exact: bool = False,
**kwargs: Any,
) -> AsyncArray:
"""Obtain an array, creating if it doesn't exist.

Other `kwargs` are as per :func:`zarr.AsyncGroup.create_dataset`.

Parameters
----------
name : string
Expand Down