Skip to content

Commit

Permalink
More checks for supported eltypes in tests. (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt authored Mar 2, 2022
1 parent 86cbb7e commit 9412fa1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
34 changes: 17 additions & 17 deletions test/testsuite/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,23 @@ end
end

@testset "cat" begin
@test compare(hcat, AT, rand(3), rand(3))
@test compare(hcat, AT, rand(), rand(1, 3))
@test compare(hcat, AT, rand(1, 3), rand())
@test compare(hcat, AT, rand(3), rand(3, 3))
@test compare(hcat, AT, rand(3, 3), rand(3))
@test compare(hcat, AT, rand(3, 3), rand(3, 3))
#@test compare(hcat, AT, rand(), rand(3, 3))
#@test compare(hcat, AT, rand(3, 3), rand())

@test compare(vcat, AT, rand(3), rand(3))
@test compare(vcat, AT, rand(3, 3), rand(3, 3))
@test compare(vcat, AT, rand(), rand(3))
@test compare(vcat, AT, rand(3), rand())
@test compare(vcat, AT, rand(), rand(3, 3))
#@test compare(vcat, AT, rand(3, 3), rand())

@test compare((a,b) -> cat(a, b; dims=4), AT, rand(3, 4), rand(3, 4))
@test compare(hcat, AT, rand(Float32, 3), rand(Float32, 3))
@test compare(hcat, AT, rand(Float32, ), rand(Float32, 1, 3))
@test compare(hcat, AT, rand(Float32, 1, 3), rand(Float32))
@test compare(hcat, AT, rand(Float32, 3), rand(Float32, 3, 3))
@test compare(hcat, AT, rand(Float32, 3, 3), rand(Float32, 3))
@test compare(hcat, AT, rand(Float32, 3, 3), rand(Float32, 3, 3))
#@test compare(hcat, AT, rand(Float32, ), rand(Float32, 3, 3))
#@test compare(hcat, AT, rand(Float32, 3, 3), rand(Float32))

@test compare(vcat, AT, rand(Float32, 3), rand(Float32, 3))
@test compare(vcat, AT, rand(Float32, 3, 3), rand(Float32, 3, 3))
@test compare(vcat, AT, rand(Float32, ), rand(Float32, 3))
@test compare(vcat, AT, rand(Float32, 3), rand(Float32))
@test compare(vcat, AT, rand(Float32, ), rand(Float32, 3, 3))
#@test compare(vcat, AT, rand(Float32, 3, 3), rand(Float32))

@test compare((a,b) -> cat(a, b; dims=4), AT, rand(Float32, 3, 4), rand(Float32, 3, 4))
end

@testset "reshape" begin
Expand Down
4 changes: 4 additions & 0 deletions test/testsuite/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ end
if T == Int8
continue
end
if !in(typeof(float(zero(T))), eltypes)
# norm promotes to float, so make sure that type is supported
continue
end
range = real(T) <: Integer ? (T.(1:10)) : T # prevent integer overflow
@test compare(norm, AT, rand(range, sz), Ref(p))
@test typeof(norm(rand(range, sz))) <: Real
Expand Down
7 changes: 5 additions & 2 deletions test/testsuite/reductions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ end
(10,)=>:, (10,10)=>:, (10,10,10)=>:,
(10,10,10)=>[1], (10,10,10)=>[2], (10,10,10)=>[3]]
@test compare(A->sum(A), AT, rand(range, sz))
@test compare(A->sum(abs, A), AT, rand(range, sz))
@test compare(A->sum(A; dims=dims), AT, rand(range, sz))
@test compare(A->prod(A), AT, rand(range, sz))
@test compare(A->prod(abs, A), AT, rand(range, sz))
@test compare(A->prod(A; dims=dims), AT, rand(range, sz))
if typeof(abs(rand(range))) in eltypes
# abs(::Complex{Int}) promotes to Float64
@test compare(A->sum(abs, A), AT, rand(range, sz))
@test compare(A->prod(abs, A), AT, rand(range, sz))
end
end

if ET in (Float32, Float64, Int64, ComplexF32, ComplexF64)
Expand Down

0 comments on commit 9412fa1

Please sign in to comment.