File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1165,7 +1165,16 @@ async def create_dataset(
11651165 .. deprecated:: 3.0.0
11661166 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 (
You can’t perform that action at this time.
0 commit comments