@@ -68,14 +68,14 @@ class TestDecodeInto2D:
6868 def test_c_contiguous (self , simple_mask ):
6969 """Test with C-contiguous array."""
7070 arr = np .zeros ((100 , 100 ), dtype = np .uint8 , order = 'C' )
71- simple_mask .decode_into (arr , value = 255 )
71+ simple_mask .decode_into (arr , fg_value = 255 )
7272 assert np .sum (arr == 255 ) == simple_mask .area ()
7373 assert np .sum (arr == 0 ) == 100 * 100 - simple_mask .area ()
7474
7575 def test_f_contiguous (self , simple_mask ):
7676 """Test with F-contiguous (Fortran order) array."""
7777 arr = np .zeros ((100 , 100 ), dtype = np .uint8 , order = 'F' )
78- simple_mask .decode_into (arr , value = 255 )
78+ simple_mask .decode_into (arr , fg_value = 255 )
7979 assert np .sum (arr == 255 ) == simple_mask .area ()
8080
8181 def test_strided_from_hwc (self , simple_mask ):
@@ -85,7 +85,7 @@ def test_strided_from_hwc(self, simple_mask):
8585 assert not channel .flags .c_contiguous
8686 assert not channel .flags .f_contiguous
8787
88- simple_mask .decode_into (channel , value = 128 )
88+ simple_mask .decode_into (channel , fg_value = 128 )
8989 assert np .sum (img [:, :, 0 ] == 128 ) == simple_mask .area ()
9090 # Other channels should be unchanged
9191 assert np .sum (img [:, :, 1 ]) == 0
@@ -98,25 +98,25 @@ def test_strided_every_other_row(self, simple_mask):
9898 assert not strided .flags .c_contiguous
9999 assert not strided .flags .f_contiguous
100100
101- simple_mask .decode_into (strided , value = 200 )
101+ simple_mask .decode_into (strided , fg_value = 200 )
102102 assert np .sum (strided == 200 ) == simple_mask .area ()
103103
104104 def test_empty_mask (self , empty_mask ):
105105 """Test with empty mask - array should remain unchanged."""
106106 arr = np .ones ((100 , 100 ), dtype = np .uint8 ) * 50
107- empty_mask .decode_into (arr , value = 255 )
107+ empty_mask .decode_into (arr , fg_value = 255 )
108108 assert np .all (arr == 50 )
109109
110110 def test_full_mask (self , full_mask ):
111111 """Test with full mask - all pixels should be set."""
112112 arr = np .zeros ((100 , 100 ), dtype = np .uint8 )
113- full_mask .decode_into (arr , value = 255 )
113+ full_mask .decode_into (arr , fg_value = 255 )
114114 assert np .all (arr == 255 )
115115
116116 def test_value_zero (self , simple_mask ):
117- """Test with value =0 - should write zeros to foreground pixels."""
117+ """Test with fg_value =0 - should write zeros to foreground pixels."""
118118 arr = np .ones ((100 , 100 ), dtype = np .uint8 ) * 100
119- simple_mask .decode_into (arr , value = 0 )
119+ simple_mask .decode_into (arr , fg_value = 0 )
120120 # Foreground pixels should be 0, background should remain 100
121121 bool_mask = simple_mask .to_array ().astype (bool )
122122 assert np .all (arr [bool_mask ] == 0 )
@@ -125,16 +125,16 @@ def test_value_zero(self, simple_mask):
125125 def test_nonzero_value_on_nonzero_array (self , simple_mask ):
126126 """Test overwriting non-zero values."""
127127 arr = np .ones ((100 , 100 ), dtype = np .uint8 ) * 100
128- simple_mask .decode_into (arr , value = 200 )
128+ simple_mask .decode_into (arr , fg_value = 200 )
129129 bool_mask = simple_mask .to_array ().astype (bool )
130130 assert np .all (arr [bool_mask ] == 200 )
131131 assert np .all (arr [~ bool_mask ] == 100 )
132132
133133 def test_overlay_multiple_masks (self , simple_mask , sparse_mask ):
134134 """Test overlaying multiple masks."""
135135 arr = np .zeros ((100 , 100 ), dtype = np .uint8 )
136- simple_mask .decode_into (arr , value = 100 )
137- sparse_mask .decode_into (arr , value = 200 )
136+ simple_mask .decode_into (arr , fg_value = 100 )
137+ sparse_mask .decode_into (arr , fg_value = 200 )
138138
139139 # sparse_mask pixels should override simple_mask where they overlap
140140 sparse_bool = sparse_mask .to_array ().astype (bool )
@@ -152,23 +152,23 @@ class TestDecodeInto3D:
152152 def test_broadcast_c_contiguous (self , simple_mask ):
153153 """Test broadcast scalar to C-contiguous HWC array."""
154154 img = np .zeros ((100 , 100 , 3 ), dtype = np .uint8 , order = 'C' )
155- simple_mask .decode_into (img , value = 128 )
155+ simple_mask .decode_into (img , fg_value = 128 )
156156
157157 for c in range (3 ):
158158 assert np .sum (img [:, :, c ] == 128 ) == simple_mask .area ()
159159
160160 def test_broadcast_f_contiguous (self , simple_mask ):
161161 """Test broadcast scalar to F-contiguous HWC array."""
162162 img = np .zeros ((100 , 100 , 3 ), dtype = np .uint8 , order = 'F' )
163- simple_mask .decode_into (img , value = 128 )
163+ simple_mask .decode_into (img , fg_value = 128 )
164164
165165 for c in range (3 ):
166166 assert np .sum (img [:, :, c ] == 128 ) == simple_mask .area ()
167167
168168 def test_rgb_values_c_contiguous (self , simple_mask ):
169169 """Test per-channel RGB values with C-contiguous array."""
170170 img = np .zeros ((100 , 100 , 3 ), dtype = np .uint8 , order = 'C' )
171- simple_mask .decode_into (img , value = (255 , 128 , 64 ))
171+ simple_mask .decode_into (img , fg_value = (255 , 128 , 64 ))
172172
173173 assert np .sum (img [:, :, 0 ] == 255 ) == simple_mask .area ()
174174 assert np .sum (img [:, :, 1 ] == 128 ) == simple_mask .area ()
@@ -177,7 +177,7 @@ def test_rgb_values_c_contiguous(self, simple_mask):
177177 def test_rgb_values_f_contiguous (self , simple_mask ):
178178 """Test per-channel RGB values with F-contiguous array."""
179179 img = np .zeros ((100 , 100 , 3 ), dtype = np .uint8 , order = 'F' )
180- simple_mask .decode_into (img , value = (255 , 128 , 64 ))
180+ simple_mask .decode_into (img , fg_value = (255 , 128 , 64 ))
181181
182182 assert np .sum (img [:, :, 0 ] == 255 ) == simple_mask .area ()
183183 assert np .sum (img [:, :, 1 ] == 128 ) == simple_mask .area ()
@@ -186,7 +186,7 @@ def test_rgb_values_f_contiguous(self, simple_mask):
186186 def test_rgba_4_channels (self , simple_mask ):
187187 """Test 4-channel RGBA array."""
188188 img = np .zeros ((100 , 100 , 4 ), dtype = np .uint8 )
189- simple_mask .decode_into (img , value = (255 , 128 , 64 , 200 ))
189+ simple_mask .decode_into (img , fg_value = (255 , 128 , 64 , 200 ))
190190
191191 assert np .sum (img [:, :, 0 ] == 255 ) == simple_mask .area ()
192192 assert np .sum (img [:, :, 1 ] == 128 ) == simple_mask .area ()
@@ -196,7 +196,7 @@ def test_rgba_4_channels(self, simple_mask):
196196 def test_single_channel_3d (self , simple_mask ):
197197 """Test single-channel 3D array (H, W, 1)."""
198198 img = np .zeros ((100 , 100 , 1 ), dtype = np .uint8 )
199- simple_mask .decode_into (img , value = (128 ,))
199+ simple_mask .decode_into (img , fg_value = (128 ,))
200200 assert np .sum (img [:, :, 0 ] == 128 ) == simple_mask .area ()
201201
202202 def test_many_channels (self , simple_mask ):
@@ -211,14 +211,14 @@ def test_many_channels(self, simple_mask):
211211 def test_list_values (self , simple_mask ):
212212 """Test with list instead of tuple for values."""
213213 img = np .zeros ((100 , 100 , 3 ), dtype = np .uint8 )
214- simple_mask .decode_into (img , value = [255 , 128 , 64 ])
214+ simple_mask .decode_into (img , fg_value = [255 , 128 , 64 ])
215215
216216 assert np .sum (img [:, :, 0 ] == 255 ) == simple_mask .area ()
217217
218218 def test_numpy_array_values (self , simple_mask ):
219219 """Test with numpy array for values."""
220220 img = np .zeros ((100 , 100 , 3 ), dtype = np .uint8 )
221- simple_mask .decode_into (img , value = np .array ([255 , 128 , 64 ]))
221+ simple_mask .decode_into (img , fg_value = np .array ([255 , 128 , 64 ]))
222222
223223 assert np .sum (img [:, :, 0 ] == 255 ) == simple_mask .area ()
224224
@@ -232,25 +232,25 @@ def test_shape_mismatch_2d(self, simple_mask):
232232 """Test error on shape mismatch for 2D array."""
233233 arr = np .zeros ((50 , 50 ), dtype = np .uint8 )
234234 with pytest .raises (ValueError , match = "shape" ):
235- simple_mask .decode_into (arr , value = 255 )
235+ simple_mask .decode_into (arr , fg_value = 255 )
236236
237237 def test_shape_mismatch_3d (self , simple_mask ):
238238 """Test error on shape mismatch for 3D array."""
239239 img = np .zeros ((50 , 50 , 3 ), dtype = np .uint8 )
240240 with pytest .raises (ValueError , match = "shape" ):
241- simple_mask .decode_into (img , value = 255 )
241+ simple_mask .decode_into (img , fg_value = 255 )
242242
243243 def test_wrong_value_length (self , simple_mask ):
244244 """Test error when value length doesn't match channels."""
245245 img = np .zeros ((100 , 100 , 3 ), dtype = np .uint8 )
246246 with pytest .raises (ValueError , match = "length" ):
247- simple_mask .decode_into (img , value = (255 , 128 )) # Only 2 values for 3 channels
247+ simple_mask .decode_into (img , fg_value = (255 , 128 )) # Only 2 values for 3 channels
248248
249249 def test_wrong_ndim (self , simple_mask ):
250250 """Test error for wrong number of dimensions."""
251251 arr = np .zeros ((100 ,), dtype = np .uint8 )
252252 with pytest .raises (ValueError , match = "2D or 3D" ):
253- simple_mask .decode_into (arr , value = 255 )
253+ simple_mask .decode_into (arr , fg_value = 255 )
254254
255255 def test_non_contiguous_3d_error (self , simple_mask ):
256256 """Test error for non-contiguous 3D array."""
@@ -260,7 +260,7 @@ def test_non_contiguous_3d_error(self, simple_mask):
260260 assert not strided .flags .f_contiguous
261261
262262 with pytest .raises (ValueError , match = "contiguous" ):
263- simple_mask .decode_into (strided , value = 255 )
263+ simple_mask .decode_into (strided , fg_value = 255 )
264264
265265
266266# --- Hypothesis property-based tests ---
@@ -298,7 +298,7 @@ def test_2d_matches_reference(self, hw, density, value, order):
298298
299299 # Test array
300300 arr = np .zeros ((h , w ), dtype = np .uint8 , order = order )
301- mask .decode_into (arr , value = value )
301+ mask .decode_into (arr , fg_value = value )
302302
303303 # Reference
304304 ref = np .zeros ((h , w ), dtype = np .uint8 , order = order )
@@ -323,7 +323,7 @@ def test_strided_matches_reference(self, hw, density, value):
323323 img = np .zeros ((h , w , 3 ), dtype = np .uint8 )
324324 channel = img [:, :, 1 ] # Middle channel, strided
325325
326- mask .decode_into (channel , value = value )
326+ mask .decode_into (channel , fg_value = value )
327327
328328 # Reference
329329 ref = np .zeros ((h , w ), dtype = np .uint8 )
@@ -346,7 +346,7 @@ def test_3d_broadcast_matches_reference(self, hw, density, value, order):
346346 mask = RLEMask (mask_arr )
347347
348348 img = np .zeros ((h , w , 3 ), dtype = np .uint8 , order = order )
349- mask .decode_into (img , value = value )
349+ mask .decode_into (img , fg_value = value )
350350
351351 ref = np .zeros ((h , w , 3 ), dtype = np .uint8 , order = order )
352352 reference_decode_into_3d_broadcast (mask , ref , value )
@@ -368,7 +368,7 @@ def test_3d_values_matches_reference(self, hw, density, values, order):
368368 mask = RLEMask (mask_arr )
369369
370370 img = np .zeros ((h , w , 3 ), dtype = np .uint8 , order = order )
371- mask .decode_into (img , value = values )
371+ mask .decode_into (img , fg_value = values )
372372
373373 ref = np .zeros ((h , w , 3 ), dtype = np .uint8 , order = order )
374374 reference_decode_into_3d_values (mask , ref , values )
@@ -389,7 +389,7 @@ def test_rgba_4channel(self, hw, density):
389389
390390 values = (255 , 128 , 64 , 200 )
391391 img = np .zeros ((h , w , 4 ), dtype = np .uint8 )
392- mask .decode_into (img , value = values )
392+ mask .decode_into (img , fg_value = values )
393393
394394 ref = np .zeros ((h , w , 4 ), dtype = np .uint8 )
395395 reference_decode_into_3d_values (mask , ref , values )
@@ -406,21 +406,21 @@ def test_1x1_mask(self):
406406 """Test with 1x1 mask."""
407407 mask = RLEMask (np .array ([[1 ]], dtype = np .uint8 ))
408408 arr = np .zeros ((1 , 1 ), dtype = np .uint8 )
409- mask .decode_into (arr , value = 255 )
409+ mask .decode_into (arr , fg_value = 255 )
410410 assert arr [0 , 0 ] == 255
411411
412412 def test_1xn_mask (self ):
413413 """Test with 1xN mask."""
414414 mask = RLEMask (np .array ([[1 , 0 , 1 , 1 , 0 ]], dtype = np .uint8 ))
415415 arr = np .zeros ((1 , 5 ), dtype = np .uint8 )
416- mask .decode_into (arr , value = 100 )
416+ mask .decode_into (arr , fg_value = 100 )
417417 np .testing .assert_array_equal (arr , [[100 , 0 , 100 , 100 , 0 ]])
418418
419419 def test_nx1_mask (self ):
420420 """Test with Nx1 mask."""
421421 mask = RLEMask (np .array ([[1 ], [0 ], [1 ]], dtype = np .uint8 ))
422422 arr = np .zeros ((3 , 1 ), dtype = np .uint8 )
423- mask .decode_into (arr , value = 100 )
423+ mask .decode_into (arr , fg_value = 100 )
424424 np .testing .assert_array_equal (arr , [[100 ], [0 ], [100 ]])
425425
426426 def test_alternating_pixels (self ):
@@ -432,7 +432,7 @@ def test_alternating_pixels(self):
432432 mask = RLEMask (mask_arr )
433433
434434 arr = np .zeros ((h , w ), dtype = np .uint8 )
435- mask .decode_into (arr , value = 255 )
435+ mask .decode_into (arr , fg_value = 255 )
436436
437437 np .testing .assert_array_equal (arr , mask_arr * 255 )
438438
@@ -446,7 +446,7 @@ def test_single_pixel_corners(self):
446446 mask = RLEMask (mask_arr )
447447
448448 arr = np .zeros ((100 , 100 ), dtype = np .uint8 )
449- mask .decode_into (arr , value = 255 )
449+ mask .decode_into (arr , fg_value = 255 )
450450
451451 assert arr [0 , 0 ] == 255
452452 assert arr [0 , 99 ] == 255
@@ -461,7 +461,7 @@ def test_preserves_existing_values(self):
461461 mask = RLEMask (mask_arr )
462462
463463 arr = np .full ((10 , 10 ), 50 , dtype = np .uint8 )
464- mask .decode_into (arr , value = 200 )
464+ mask .decode_into (arr , fg_value = 200 )
465465
466466 bool_mask = mask_arr .astype (bool )
467467 assert np .all (arr [bool_mask ] == 200 )
0 commit comments