11from __future__ import annotations
22
33import re
4- from typing import TYPE_CHECKING , get_args
4+ from typing import TYPE_CHECKING , Any
55
66import zarr .codecs
77import zarr .storage
@@ -77,16 +77,22 @@ def test_create(memory_store: Store) -> None:
7777 z = create (shape = (400 , 100 ), chunks = (16 , 16.5 ), store = store , overwrite = True ) # type: ignore [arg-type]
7878
7979
80- LikeFuncName = Literal ["zeros_like" , "ones_like" , "empty_like" , "full_like" , "open_like" ]
81-
82-
83- @pytest .mark .parametrize ("func_name" , get_args (LikeFuncName ))
80+ @pytest .mark .parametrize (
81+ "func" ,
82+ [
83+ zarr .api .asynchronous .zeros_like ,
84+ zarr .api .asynchronous .ones_like ,
85+ zarr .api .asynchronous .empty_like ,
86+ zarr .api .asynchronous .full_like ,
87+ zarr .api .asynchronous .open_like ,
88+ ],
89+ )
8490@pytest .mark .parametrize ("out_shape" , ["keep" , (10 , 10 )])
8591@pytest .mark .parametrize ("out_chunks" , ["keep" , (10 , 10 )])
8692@pytest .mark .parametrize ("out_dtype" , ["keep" , "int8" ])
8793async def test_array_like_creation (
8894 zarr_format : ZarrFormat ,
89- func_name : LikeFuncName ,
95+ func : Callable [[ Any ], Any ] ,
9096 out_shape : Literal ["keep" ] | tuple [int , ...],
9197 out_chunks : Literal ["keep" ] | tuple [int , ...],
9298 out_dtype : str ,
@@ -100,23 +106,18 @@ async def test_array_like_creation(
100106 store = {}, shape = (11 , 12 ), dtype = "uint8" , chunks = (11 , 12 ), zarr_format = zarr_format
101107 )
102108 kwargs : dict [str , object ] = {}
103- if func_name == " full_like" :
109+ if func is zarr . api . asynchronous . full_like :
104110 expect_fill = 4
105111 kwargs ["fill_value" ] = expect_fill
106- func = zarr .api .asynchronous .full_like
107- elif func_name == "zeros_like" :
112+ elif func is zarr .api .asynchronous .zeros_like :
108113 expect_fill = 0
109- func = zarr .api .asynchronous .zeros_like
110- elif func_name == "ones_like" :
114+ elif func is zarr .api .asynchronous .ones_like :
111115 expect_fill = 1
112- func = zarr .api .asynchronous .ones_like
113- elif func_name == "empty_like" :
116+ elif func is zarr .api .asynchronous .empty_like :
114117 expect_fill = ref_arr .fill_value
115- func = zarr .api .asynchronous .empty_like
116- elif func_name == "open_like" :
118+ elif func is zarr .api .asynchronous .open_like : # type: ignore[assignment]
117119 expect_fill = ref_arr .fill_value
118120 kwargs ["mode" ] = "w"
119- func = zarr .api .asynchronous .open_like # type: ignore[assignment]
120121 else :
121122 raise AssertionError
122123 if out_shape != "keep" :
@@ -135,7 +136,7 @@ async def test_array_like_creation(
135136 else :
136137 expect_dtype = ref_arr .dtype # type: ignore[assignment]
137138
138- new_arr = await func (ref_arr , path = "foo" , ** kwargs )
139+ new_arr = await func (ref_arr , path = "foo" , ** kwargs ) # type: ignore[call-arg]
139140 assert new_arr .shape == expect_shape
140141 assert new_arr .chunks == expect_chunks
141142 assert new_arr .dtype == expect_dtype
0 commit comments