Skip to content

Commit c1eb41d

Browse files
authored
Merge pull request #9 from martinholters/fix_normalization_inference
Add a typeassert in `normalization`
2 parents 486ce50 + cc853d9 commit c1eb41d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/definitions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ summary(p::ScaledPlan) = string(p.scale, " * ", summary(p.p))
255255
*(p::Plan, I::UniformScaling) = ScaledPlan(p, I.λ)
256256

257257
# Normalization for ifft, given unscaled bfft, is 1/prod(dimensions)
258-
normalization(T, sz, region) = one(T) / Int(prod([sz...][[region...]]))
258+
normalization(T, sz, region) = one(T) / Int(prod([sz...][[region...]]))::Int
259259
normalization(X, region) = normalization(real(eltype(X)), size(X), region)
260260

261261
plan_ifft(x::AbstractArray, region; kws...) =

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,11 @@ end
7979
@test AbstractFFTs.ifftshift([1 2 3; 4 5 6], (1,2)) == [5 6 4; 2 3 1]
8080
@test AbstractFFTs.ifftshift([1 2 3; 4 5 6], 1:2) == [5 6 4; 2 3 1]
8181
end
82+
83+
@testset "normalization" begin
84+
# normalization should be inferable even if region is only inferred as ::Any,
85+
# need to wrap in another function to test this (note that p.region::Any for
86+
# p::TestPlan)
87+
f9(p::Plan{T}, sz) where {T} = AbstractFFTs.normalization(real(T), sz, p.region)
88+
@test @inferred(f9(plan_fft(zeros(10), 1), 10)) == 1/10
89+
end

0 commit comments

Comments
 (0)