@@ -1148,6 +1148,9 @@ async def create_dataset(
11481148 ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
11491149 """Create an array.
11501150
1151+ .. deprecated:: 3.0.0
1152+ The h5py compatibility methods will be removed in 3.1.0. Use `AsyncGroup.create_array` instead.
1153+
11511154 Arrays are known as "datasets" in HDF5 terminology. For compatibility
11521155 with h5py, Zarr groups also implement the :func:`zarr.AsyncGroup.require_dataset` method.
11531156
@@ -1161,11 +1164,17 @@ async def create_dataset(
11611164 Returns
11621165 -------
11631166 a : AsyncArray
1164-
1165- .. deprecated:: 3.0.0
1166- The h5py compatibility methods will be removed in 3.1.0. Use `AsyncGroup.create_array` instead.
11671167 """
1168- return await self .create_array (name , shape = shape , ** kwargs )
1168+ data = kwargs .pop ("data" , None )
1169+ # create_dataset in zarr 2.x requires shape but not dtype if data is
1170+ # provided. Allow this configuration by inferring dtype from data if
1171+ # necessary and passing it to create_array
1172+ if "dtype" not in kwargs and data is not None :
1173+ kwargs ["dtype" ] = data .dtype
1174+ array = await self .create_array (name , shape = shape , ** kwargs )
1175+ if data is not None :
1176+ await array .setitem (slice (None ), data )
1177+ return array
11691178
11701179 @deprecated ("Use AsyncGroup.require_array instead." )
11711180 async def require_dataset (
@@ -1179,6 +1188,9 @@ async def require_dataset(
11791188 ) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
11801189 """Obtain an array, creating if it doesn't exist.
11811190
1191+ .. deprecated:: 3.0.0
1192+ The h5py compatibility methods will be removed in 3.1.0. Use `AsyncGroup.require_dataset` instead.
1193+
11821194 Arrays are known as "datasets" in HDF5 terminology. For compatibility
11831195 with h5py, Zarr groups also implement the :func:`zarr.AsyncGroup.create_dataset` method.
11841196
@@ -1199,9 +1211,6 @@ async def require_dataset(
11991211 Returns
12001212 -------
12011213 a : AsyncArray
1202-
1203- .. deprecated:: 3.0.0
1204- The h5py compatibility methods will be removed in 3.1.0. Use `AsyncGroup.require_dataset` instead.
12051214 """
12061215 return await self .require_array (name , shape = shape , dtype = dtype , exact = exact , ** kwargs )
12071216
@@ -2393,6 +2402,10 @@ def create_array(
23932402 def create_dataset (self , name : str , ** kwargs : Any ) -> Array :
23942403 """Create an array.
23952404
2405+ .. deprecated:: 3.0.0
2406+ The h5py compatibility methods will be removed in 3.1.0. Use `Group.create_array` instead.
2407+
2408+
23962409 Arrays are known as "datasets" in HDF5 terminology. For compatibility
23972410 with h5py, Zarr groups also implement the :func:`zarr.Group.require_dataset` method.
23982411
@@ -2406,16 +2419,16 @@ def create_dataset(self, name: str, **kwargs: Any) -> Array:
24062419 Returns
24072420 -------
24082421 a : Array
2409-
2410- .. deprecated:: 3.0.0
2411- The h5py compatibility methods will be removed in 3.1.0. Use `Group.create_array` instead.
24122422 """
24132423 return Array (self ._sync (self ._async_group .create_dataset (name , ** kwargs )))
24142424
24152425 @deprecated ("Use Group.require_array instead." )
24162426 def require_dataset (self , name : str , * , shape : ShapeLike , ** kwargs : Any ) -> Array :
24172427 """Obtain an array, creating if it doesn't exist.
24182428
2429+ .. deprecated:: 3.0.0
2430+ The h5py compatibility methods will be removed in 3.1.0. Use `Group.require_array` instead.
2431+
24192432 Arrays are known as "datasets" in HDF5 terminology. For compatibility
24202433 with h5py, Zarr groups also implement the :func:`zarr.Group.create_dataset` method.
24212434
@@ -2431,9 +2444,6 @@ def require_dataset(self, name: str, *, shape: ShapeLike, **kwargs: Any) -> Arra
24312444 Returns
24322445 -------
24332446 a : Array
2434-
2435- .. deprecated:: 3.0.0
2436- The h5py compatibility methods will be removed in 3.1.0. Use `Group.require_array` instead.
24372447 """
24382448 return Array (self ._sync (self ._async_group .require_array (name , shape = shape , ** kwargs )))
24392449
@@ -2660,6 +2670,9 @@ def array(
26602670 ) -> Array :
26612671 """Create an array within this group.
26622672
2673+ .. deprecated:: 3.0.0
2674+ Use `Group.create_array` instead.
2675+
26632676 This method lightly wraps :func:`zarr.core.array.create_array`.
26642677
26652678 Parameters
0 commit comments