@@ -108,10 +108,10 @@ def _get_shape_chunks(a: ArrayLike | Any) -> tuple[ChunkCoords | None, ChunkCoor
108108 return shape , chunks
109109
110110
111- def _like_args (a : ArrayLike , kwargs : dict [ str , Any ] ) -> dict [str , Any ]:
111+ def _like_args (a : ArrayLike ) -> dict [str , object ]:
112112 """Set default values for shape and chunks if they are not present in the array-like object"""
113113
114- new = kwargs . copy ()
114+ new : dict [ str , object ] = {}
115115
116116 shape , chunks = _get_shape_chunks (a )
117117 if shape is not None :
@@ -1077,7 +1077,7 @@ async def empty(
10771077 shape : ChunkCoords , ** kwargs : Any
10781078) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
10791079 """Create an empty array with the specified shape. The contents will be filled with the
1080- array's fill value or zeros if no fill value is provided.
1080+ specified fill value or zeros if no fill value is provided.
10811081
10821082 Parameters
10831083 ----------
@@ -1092,8 +1092,9 @@ async def empty(
10921092 retrieve data from an empty Zarr array, any values may be returned,
10931093 and these are not guaranteed to be stable from one access to the next.
10941094 """
1095-
1096- return await create (shape = shape , fill_value = None , ** kwargs )
1095+ if "fill_value" not in kwargs :
1096+ kwargs ["fill_value" ] = None
1097+ return await create (shape = shape , ** kwargs )
10971098
10981099
10991100async def empty_like (
@@ -1120,8 +1121,10 @@ async def empty_like(
11201121 retrieve data from an empty Zarr array, any values may be returned,
11211122 and these are not guaranteed to be stable from one access to the next.
11221123 """
1123- like_kwargs = _like_args (a , kwargs )
1124- return await empty (** like_kwargs )
1124+ like_kwargs = _like_args (a ) | kwargs
1125+ if isinstance (a , (AsyncArray | Array )):
1126+ kwargs .setdefault ("fill_value" , a .metadata .fill_value )
1127+ return await empty (** like_kwargs ) # type: ignore[arg-type]
11251128
11261129
11271130# TODO: add type annotations for fill_value and kwargs
@@ -1166,10 +1169,10 @@ async def full_like(
11661169 Array
11671170 The new array.
11681171 """
1169- like_kwargs = _like_args (a , kwargs )
1170- if isinstance (a , AsyncArray ):
1171- like_kwargs .setdefault ("fill_value" , a .metadata .fill_value )
1172- return await full (** like_kwargs )
1172+ like_kwargs = _like_args (a ) | kwargs
1173+ if isinstance (a , ( AsyncArray | Array ) ):
1174+ kwargs .setdefault ("fill_value" , a .metadata .fill_value )
1175+ return await full (** like_kwargs ) # type: ignore[arg-type]
11731176
11741177
11751178async def ones (
@@ -1210,8 +1213,8 @@ async def ones_like(
12101213 Array
12111214 The new array.
12121215 """
1213- like_kwargs = _like_args (a , kwargs )
1214- return await ones (** like_kwargs )
1216+ like_kwargs = _like_args (a ) | kwargs
1217+ return await ones (** like_kwargs ) # type: ignore[arg-type]
12151218
12161219
12171220async def open_array (
@@ -1291,10 +1294,10 @@ async def open_like(
12911294 AsyncArray
12921295 The opened array.
12931296 """
1294- like_kwargs = _like_args (a , kwargs )
1297+ like_kwargs = _like_args (a ) | kwargs
12951298 if isinstance (a , (AsyncArray | Array )):
12961299 kwargs .setdefault ("fill_value" , a .metadata .fill_value )
1297- return await open_array (path = path , ** like_kwargs )
1300+ return await open_array (path = path , ** like_kwargs ) # type: ignore[arg-type]
12981301
12991302
13001303async def zeros (
@@ -1335,5 +1338,5 @@ async def zeros_like(
13351338 Array
13361339 The new array.
13371340 """
1338- like_kwargs = _like_args (a , kwargs )
1339- return await zeros (** like_kwargs )
1341+ like_kwargs = _like_args (a ) | kwargs
1342+ return await zeros (** like_kwargs ) # type: ignore[arg-type]
0 commit comments