Skip to content

Commit

Permalink
Remove explicit bounds checking
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Feb 6, 2024
1 parent 629ac70 commit b9eb1dc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
9 changes: 1 addition & 8 deletions src/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,8 @@ summary(p::ScaledPlan) = string(p.scale, " * ", summary(p.p))
*(I::UniformScaling, p::Plan) = ScaledPlan(p, I.λ)
*(p::Plan, I::UniformScaling) = ScaledPlan(p, I.λ)

# Normalization for ifft, given unscaled bfft, is 1/prod(dimensions)
# ensure that region is a subset of eachindex(sz).
_checkindex(szinds, region::AbstractVector) = checkindex(Bool, szinds, region)
# this method handles the case where region is not an array, e.g. it is a Tuple
_checkindex(szinds, region) = all(r -> checkindex(Bool, szinds, r), region)
@inline function normalization(::Type{T}, sz, region) where T
@boundscheck (!isempty(region) && _checkindex(eachindex(sz), region)) ||
throw(BoundsError(sz, region))
one(T) / mapreduce(r -> Int(@inbounds sz[r])::Int, *, region; init=1)::Int
one(T) / mapreduce(r -> Int(sz[r])::Int, *, region; init=1)::Int
end

Check warning on line 275 in src/definitions.jl

View check run for this annotation

Codecov / codecov/patch

src/definitions.jl#L273-L275

Added lines #L273 - L275 were not covered by tests
normalization(X, region) = normalization(real(eltype(X)), size(X), region)

Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ end
@test @inferred(f9(plan_fft(zeros(10), 1), 10)) == 1/10

@test_throws BoundsError AbstractFFTs.normalization(Float64, (2,), 1:3)
@test_throws BoundsError AbstractFFTs.normalization(Float64, (2,), Int[])
# @test_throws BoundsError AbstractFFTs.normalization(Float64, (2,), Int[])
@test_throws BoundsError AbstractFFTs.normalization(Float64, (2,), (1,3,))
end

Expand Down

0 comments on commit b9eb1dc

Please sign in to comment.