Skip to content

Commit

Permalink
Fix bug in lenses and add simplistic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roflmaostc committed Nov 13, 2020
1 parent 6c47e9b commit 1db518d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/lenses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function lens(f::Number, L::Number, size::Tuple=(512, 512); radius=Inf, λ=550e-
out = zeros(ComplexF64, size)

# iterate over values
for (j, x) in enumerate(fftpos(L, size(arr)[2]))
for (i, y) in enumerate(range(L, size(arr)[1]))
for (j, x) in enumerate(fftpos(L, size[2]))
for (i, y) in enumerate(fftpos(L, size[1]))
out[i, j] = circ(radius, x, y) * lens(f, x, y; radius=radius, λ=λ, n=n)
end
end
Expand Down
11 changes: 11 additions & 0 deletions test/lenses.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@testset "Test ideal lens" begin

arr = randn((10, 10))
@test all(abs.(lens(10.0, 12.0, size(arr), radius=1000)) .≈ 1)

arr2 = zeros(size(arr))
arr2[6, 6] = 1
@test arr2 abs.(lens(10.0, 12.0, size(arr), radius=0))


end
11 changes: 6 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ using Random
Random.seed!(42)

tests = [
"convolutions",
"utils",
"psf",
"apertures",
"convolutions",
"lenses",
"physical_conversions",
"resolution_equations",
"propagations",
"utils_view"
"psf",
"resolution_equations",
"utils",
"utils_view",
]

for t in tests
Expand Down

0 comments on commit 1db518d

Please sign in to comment.