Skip to content

Commit

Permalink
add inferred to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mileslucas committed Dec 24, 2021
1 parent 6c14213 commit 454a73f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ source = Float64.(testimage("cameraman"))
@testset "pixel shift" for _ in 1:100
shift = (rand(rng, -25:25), rand(rng, -25:25))
shifted = @inferred fourier_shift(source, shift)
result = @inferred phase_offset(source, shifted; upsample_factor=1)
result = @inferred phase_offset(source, shifted; upsample_factor = 1)
@test all(result.shift .≈ -1 .* shift)

registered = @inferred register(source, shifted; upsample_factor=1)
registered = @inferred register(source, shifted; upsample_factor = 1)
@test registered fourier_shift(shifted, result.shift, result.phasediff)
end

Expand All @@ -25,27 +25,27 @@ source = Float64.(testimage("cameraman"))
shifted = fourier_shift(source, shift)

f = 10
result = @inferred phase_offset(source, shifted; upsample_factor=f)
@test all(isapprox.(result.shift, -1 .* shift, atol=inv(f)))
result = @inferred phase_offset(source, shifted; upsample_factor = f)
@test all(isapprox.(result.shift, -1 .* shift, atol = inv(f)))

registered = @inferred register(source, shifted; upsample_factor=f)
registered = @inferred register(source, shifted; upsample_factor = f)
@test registered fourier_shift(shifted, result.shift, result.phasediff)
end

@testset "coregister" begin
shifts = 10 .* randn(rng, 19, 2)
cube = cat(source, (fourier_shift(source, shift) for shift in eachrow(shifts))..., dims=3)
cube = cat(source, (fourier_shift(source, shift) for shift in eachrow(shifts))..., dims = 3)
f = 100
cube_shift = @inferred coregister(cube; dims=3, upsample_factor=f)
for slice in eachslice(cube_shift, dims=3)
@test all(isapprox.(slice, source; atol=1e-2))
cube_shift = @inferred coregister(cube; dims = 3, upsample_factor = f)
for slice in eachslice(cube_shift, dims = 3)
@test all(isapprox.(slice, source; atol = 1e-2))
end

# alternate axis of iteration
cubep = permutedims(cube, (3, 2, 1))
cubep_shift = @inferred coregister(cubep, dims=1, upsample_factor=f)
for slice in eachslice(cubep_shift, dims=1)
@test all(isapprox.(slice', source; atol=1e-2))
cubep_shift = @inferred coregister(cubep, dims = 1, upsample_factor = f)
for slice in eachslice(cubep_shift, dims = 1)
@test all(isapprox.(slice', source; atol = 1e-2))
end
end

Expand Down

2 comments on commit 454a73f

@mileslucas
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/51202

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" 454a73f7c3c044a19568b18a5939d24104d95986
git push origin v0.2.0

Please sign in to comment.