@@ -90,33 +90,52 @@ def test_create(memory_store: Store) -> None:
90
90
@pytest .mark .parametrize ("out_shape" , ["keep" , (10 , 10 )])
91
91
@pytest .mark .parametrize ("out_chunks" , ["keep" , (10 , 10 )])
92
92
@pytest .mark .parametrize ("out_dtype" , ["keep" , "int8" ])
93
+ @pytest .mark .parametrize ("out_fill" , ["keep" , 4 ])
93
94
async def test_array_like_creation (
94
95
zarr_format : ZarrFormat ,
95
96
func : Callable [[Any ], Any ],
96
97
out_shape : Literal ["keep" ] | tuple [int , ...],
97
98
out_chunks : Literal ["keep" ] | tuple [int , ...],
98
99
out_dtype : str ,
100
+ out_fill : Literal ["keep" ] | int ,
99
101
) -> None :
100
102
"""
101
103
Test zeros_like, ones_like, empty_like, full_like, ensuring that we can override the
102
- shape, chunks, and dtype of the array-like object provided to these functions with
104
+ shape, chunks, dtype and fill_value of the array-like object provided to these functions with
103
105
appropriate keyword arguments
104
106
"""
105
- ref_arr = zarr .ones (
106
- store = {}, shape = (11 , 12 ), dtype = "uint8" , chunks = (11 , 12 ), zarr_format = zarr_format
107
+ ref_fill = 100
108
+ ref_arr = zarr .create_array (
109
+ store = {},
110
+ shape = (11 , 12 ),
111
+ dtype = "uint8" ,
112
+ chunks = (11 , 12 ),
113
+ zarr_format = zarr_format ,
114
+ fill_value = ref_fill ,
107
115
)
108
116
kwargs : dict [str , object ] = {}
109
117
if func is zarr .api .asynchronous .full_like :
110
- expect_fill = 4
111
- kwargs ["fill_value" ] = expect_fill
118
+ if out_fill == "keep" :
119
+ expect_fill = ref_fill
120
+ else :
121
+ expect_fill = out_fill
122
+ kwargs ["fill_value" ] = expect_fill
112
123
elif func is zarr .api .asynchronous .zeros_like :
113
124
expect_fill = 0
114
125
elif func is zarr .api .asynchronous .ones_like :
115
126
expect_fill = 1
116
127
elif func is zarr .api .asynchronous .empty_like :
117
- expect_fill = ref_arr .fill_value
128
+ if out_fill == "keep" :
129
+ expect_fill = ref_fill
130
+ else :
131
+ kwargs ["fill_value" ] = out_fill
132
+ expect_fill = out_fill
118
133
elif func is zarr .api .asynchronous .open_like : # type: ignore[assignment]
119
- expect_fill = ref_arr .fill_value
134
+ if out_fill == "keep" :
135
+ expect_fill = ref_fill
136
+ else :
137
+ kwargs ["fill_value" ] = out_fill
138
+ expect_fill = out_fill
120
139
kwargs ["mode" ] = "w"
121
140
else :
122
141
raise AssertionError
0 commit comments