Skip to content

Commit b8dc3d0

Browse files
committed
add more tests
1 parent 7976076 commit b8dc3d0

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

test/complexweights.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Test, Random, Flux
2+
3+
@testset "Weights" begin
4+
@testset "uniform" begin
5+
@test size(OperatorLearning.cglorot_uniform(128,64,10)) == (128, 64, 10)
6+
@test eltype(OperatorLearning.cglorot_uniform(128,64,10)) == ComplexF32
7+
end
8+
9+
@testset "normal" begin
10+
@test size(OperatorLearning.cglorot_normal(128,64,10)) == (128, 64, 10)
11+
@test eltype(OperatorLearning.cglorot_normal(128,64,10)) == ComplexF32
12+
end
13+
end

test/fourierlayer.jl

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
using Test, Random, Flux
22

33
@testset "FourierLayer" begin
4-
# Test the proper construction
5-
@test size(FourierLayer(128, 64, 100, 20).Wf) == (128, 64, 51)
6-
@test size(FourierLayer(128, 64, 100, 20).Wl) == (64, 128)
7-
#@test size(FourierLayer(10, 100).bias_f) == (51,)
8-
#@test size(FourierLayer(10, 100).bias_l) == (100,)
4+
@testset "dimensions" begin
5+
# Test the proper construction
6+
@test size(FourierLayer(128, 64, 100, 20).Wf) == (128, 64, 51)
7+
@test size(FourierLayer(128, 64, 100, 20).Wl) == (64, 128)
8+
@test size(FourierLayer(128, 64, 100, 20).bf) == (1, 64, 51)
9+
@test size(FourierLayer(128, 64, 100, 20).bl) == (1, 64, 100)
10+
end
11+
12+
# Test proper parameter assignment
13+
# We only use a subset of the weight tensors for training
14+
@testset "parameters" begin
15+
# Wf
16+
@test size(params(FourierLayer(128, 64, 100, 20))[1]) == (128, 64, 20)
17+
# Wl
18+
@test size(params(FourierLayer(128, 64, 100, 20))[2]) == (128, 64, 20)
19+
# bf
20+
@test size(params(FourierLayer(128, 64, 100, 20))[3]) == (1, 64, 20)
21+
# bl
22+
@test size(params(FourierLayer(128, 64, 100, 20))[4]) == (1, 64, 100)
23+
end
924

1025
# Accept only Int as architecture parameters
1126
@test_throws MethodError FourierLayer(128.5, 64, 100, 20)
1227
@test_throws MethodError FourierLayer(128.5, 64, 100, 20, tanh)
28+
# Test max amount of modes
1329
@test_throws AssertionError FourierLayer(100, 100, 100, 60, σ)
1430
@test_throws AssertionError FourierLayer(100, 100, 100, 60)
1531
end

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ Random.seed!(0)
77
@testset "FourierLayer" begin
88
include("fourierlayer.jl")
99
end
10+
11+
@testset "Weights" begin
12+
include("complexweights.jl")
13+
end

0 commit comments

Comments
 (0)