@@ -83,9 +83,11 @@ def func_with_args_kwargs(slice_2d, multiplier, offset=0):
8383 np .testing .assert_array_equal (result , expected )
8484
8585 def test_process_slices_empty_special_outputs (self ):
86- """Test process_slices when some slices return no special outputs ."""
86+ """Reject a tuple/non-tuple result boundary between slices ."""
8787
88- np .array ([[[1 ]], [[2 ]]])
88+ from arraybridge .slice_processing import process_slices
89+
90+ image_3d = np .array ([[[1 ]], [[2 ]]])
8991
9092 # Mix of single output and tuple output
9193 def mixed_func (slice_2d ):
@@ -94,9 +96,31 @@ def mixed_func(slice_2d):
9496 else : # Second slice
9597 return slice_2d * 3
9698
97- # This should work but might be complex; for now, assume consistent return types
98- # In practice, functions should be consistent
99- pass # Skip this test as it requires more complex logic
99+ with pytest .raises (TypeError , match = "mix tuple and non-tuple" ):
100+ process_slices (image_3d , mixed_func , (), {})
101+
102+ def test_process_slices_rejects_result_tuple_arity_drift (self ):
103+ """Reject side-output cardinality changes between slices."""
104+
105+ from arraybridge .slice_processing import process_slices
106+
107+ image_3d = np .array ([[[1 ]], [[2 ]]])
108+
109+ def drifting_func (slice_2d ):
110+ if np .sum (slice_2d ) == 1 :
111+ return slice_2d , "first"
112+ return slice_2d , "second" , "surplus"
113+
114+ with pytest .raises (ValueError , match = "same arity" ):
115+ process_slices (image_3d , drifting_func , (), {})
116+
117+ def test_process_slices_rejects_empty_result_tuple (self ):
118+ """Reject a tuple that has no declared main output."""
119+
120+ from arraybridge .slice_processing import process_slices
121+
122+ with pytest .raises (ValueError , match = "cannot be empty" ):
123+ process_slices (np .ones ((1 , 1 , 1 )), lambda _slice : (), (), {})
100124
101125 @pytest .mark .parametrize (
102126 "shape" ,
0 commit comments