@@ -207,23 +207,34 @@ end
207
207
@test isequal (prod (A, dims= (1 , 2 )), fill (1 , 1 , 1 ))
208
208
@test isequal (prod (A, dims= 3 ), fill (1 , 0 , 1 ))
209
209
210
- for f in (minimum, maximum)
210
+ for f in (minimum, maximum, findmin, findmax )
211
211
@test_throws " reducing over an empty collection is not allowed" f (A, dims= 1 )
212
- @test_throws " reducing over an empty collection is not allowed" isequal ( f (A, dims= 2 ), zeros (Int, 0 , 1 ) )
212
+ @test_throws " reducing over an empty collection is not allowed" f (A, dims= 2 )
213
213
@test_throws " reducing over an empty collection is not allowed" f (A, dims= (1 , 2 ))
214
- @test_throws " reducing over an empty collection is not allowed" isequal (f (A, dims= 3 ), zeros (Int, 0 , 1 ))
215
- end
216
- for f in (findmin, findmax)
217
- @test_throws " reducing over an empty collection is not allowed" f (A, dims= 1 )
218
- @test_throws " reducing over an empty collection is not allowed" isequal (f (A, dims= 2 ), (zeros (Int, 0 , 1 ), zeros (Int, 0 , 1 )))
219
- @test_throws " reducing over an empty collection is not allowed" f (A, dims= (1 , 2 ))
220
- @test_throws " reducing over an empty collection is not allowed" isequal (f (A, dims= 3 ), (zeros (Int, 0 , 1 ), zeros (Int, 0 , 1 )))
221
- @test_throws " reducing over an empty collection is not allowed" f (abs2, A, dims= 1 )
222
- @test_throws " reducing over an empty collection is not allowed" isequal (f (abs2, A, dims= 2 ), (zeros (Int, 0 , 1 ), zeros (Int, 0 , 1 )))
223
- @test_throws " reducing over an empty collection is not allowed" f (abs2, A, dims= (1 , 2 ))
224
- @test_throws " reducing over an empty collection is not allowed" isequal (f (abs2, A, dims= 3 ), (zeros (Int, 0 , 1 ), zeros (Int, 0 , 1 )))
214
+ @test_throws " reducing over an empty collection is not allowed" f (A, dims= 3 )
215
+ if f === maximum
216
+ # maximum allows some empty reductions with abs/abs2
217
+ z = f (abs, A)
218
+ @test isequal (f (abs, A, dims= 1 ), fill (z, (1 ,1 )))
219
+ @test isequal (f (abs, A, dims= 2 ), fill (z, (0 ,1 )))
220
+ @test isequal (f (abs, A, dims= (1 ,2 )), fill (z, (1 ,1 )))
221
+ @test isequal (f (abs, A, dims= 3 ), fill (z, (0 ,1 )))
222
+ z = f (abs2, A)
223
+ @test isequal (f (abs2, A, dims= 1 ), fill (z, (1 ,1 )))
224
+ @test isequal (f (abs2, A, dims= 2 ), fill (z, (0 ,1 )))
225
+ @test isequal (f (abs2, A, dims= (1 ,2 )), fill (z, (1 ,1 )))
226
+ @test isequal (f (abs2, A, dims= 3 ), fill (z, (0 ,1 )))
227
+ else
228
+ @test_throws " reducing over an empty collection is not allowed" f (abs, A, dims= 1 )
229
+ @test_throws " reducing over an empty collection is not allowed" f (abs, A, dims= 2 )
230
+ @test_throws " reducing over an empty collection is not allowed" f (abs, A, dims= (1 , 2 ))
231
+ @test_throws " reducing over an empty collection is not allowed" f (abs, A, dims= 3 )
232
+ @test_throws " reducing over an empty collection is not allowed" f (abs2, A, dims= 1 )
233
+ @test_throws " reducing over an empty collection is not allowed" f (abs2, A, dims= 2 )
234
+ @test_throws " reducing over an empty collection is not allowed" f (abs2, A, dims= (1 , 2 ))
235
+ @test_throws " reducing over an empty collection is not allowed" f (abs2, A, dims= 3 )
236
+ end
225
237
end
226
-
227
238
end
228
239
229
240
# # findmin/findmax/minimum/maximum
0 commit comments