-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Started adding some unit tests
- Loading branch information
1 parent
d0261f8
commit c3f43c7
Showing
2 changed files
with
49 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,44 @@ | ||
using PushPull | ||
using Test | ||
|
||
function operator_consistency(d::NTuple{3,Int64}, reg::Vector{<:AbstractFloat}, cu::Bool) | ||
bnd = [2 1 1; 1 2 1; 1 1 2] # Sliding boundary | ||
u0 = randn(Float32,(d...,3)) | ||
L = registration_operator([1,1,1], reg) | ||
Lsp = sparsify(L, d[1:3]) | ||
|
||
if cu | ||
L = CuArray(L) | ||
u0 = CuArray(u0) | ||
end | ||
|
||
K = greens(L, d); | ||
v = mom2vel(u0, K); | ||
u1 = vel2mom(v, Lsp, bnd); | ||
|
||
return sum((u1[:].-u0[:]).^2)./sum(u0[:].^2) | ||
end | ||
|
||
tol = 1e-4 | ||
@testset "PushPull.jl" begin | ||
# Write your tests here. | ||
@test operator_consistency((8,7,1),[1e-3, 0.,0.,0.], true) < tol | ||
#@test operator_consistency((8,7,1),[1e-3, 1.,0.,0.], true) < tol | ||
#@test operator_consistency((8,7,1),[1e-3, 1.,1.,0.], true) < tol | ||
#@test operator_consistency((8,7,1),[1e-3, 1.,1.,9.], true) < tol | ||
|
||
@test operator_consistency((32,32,32),[1e-3, 0.,0.,0.], true) < tol | ||
@test operator_consistency((32,32,32),[1e-3, 1.,0.,0.], true) < tol | ||
@test operator_consistency((32,32,32),[1e-3, 1.,1.,0.], true) < tol | ||
@test operator_consistency((32,32,32),[1e-3, 1.,1.,9.], true) < tol | ||
|
||
@test operator_consistency((8,7,1),[1e-3, 0.,0.,0.], false) < tol | ||
#@test operator_consistency((8,7,1),[1e-3, 1.,0.,0.], false) < tol | ||
#@test operator_consistency((8,7,1),[1e-3, 1.,1.,0.], false) < tol | ||
#@test operator_consistency((8,7,1),[1e-3, 1.,1.,9.], false) < tol | ||
@test operator_consistency((32,32,32),[1e-3, 0.,0.,0.], false) < tol | ||
@test operator_consistency((32,32,32),[1e-3, 1.,0.,0.], false) < tol | ||
@test operator_consistency((32,32,32),[1e-3, 1.,1.,0.], false) < tol | ||
@test operator_consistency((32,32,32),[1e-3, 1.,1.,9.], false) < tol | ||
end | ||
|