Skip to content

Commit

Permalink
add test for JuliaLang#43599
Browse files Browse the repository at this point in the history
  • Loading branch information
N5N3 committed Dec 30, 2021
1 parent b468dcd commit 52551e8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,27 @@ A = circshift(reshape(1:24,2,3,4), (0,1,1))
@test size(extrema(A,dims=(1,2,3))) == size(maximum(A,dims=(1,2,3)))
@test extrema(x->div(x, 2), A, dims=(2,3)) == reshape([(0,11),(1,12)],2,1,1)

function test_extrema(f, a; dims)
vext = extrema(f, a; dims)
vmin, vmax = minimum(f, a; dims), maximum(f, a; dims)
@test all(x -> x[1] === x[2:3], zip(vext,vmin,vmax))
end
@testset "NaN/missing test for extrema with dims #43599" begin
A = randn(10,10)
A[rand(1:100, 4)] .= NaN
test_extrema(identity, A; dims = 1)
test_extrema(identity, A; dims = 2)
test_extrema(identity, A; dims = (1,2))
A = map(i -> isnan(i) ? missing : i, A)
test_extrema(identity, A; dims = 1)
test_extrema(identity, A; dims = 2)
test_extrema(identity, A; dims = (1,2))
A[rand(1:100, 4)] .= NaN
test_extrema(identity, A; dims = 1)
test_extrema(identity, A; dims = 2)
test_extrema(identity, A; dims = (1,2))
end

@testset "maximum/minimum/extrema with missing values" begin
for x in (Vector{Union{Int,Missing}}(missing, 10),
Vector{Union{Int,Missing}}(missing, 257))
Expand Down

0 comments on commit 52551e8

Please sign in to comment.