-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from JuliaMath/teh/fix_#244
Avoid numerical-precision failures of bounds checking (fixes #244)
- Loading branch information
Showing
12 changed files
with
140 additions
and
191 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
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,35 +1,35 @@ | ||
module ExtrapNon1 | ||
|
||
using Test, Interpolations, OffsetArrays | ||
|
||
f(x) = sin((x-3)*2pi/9 - 1) | ||
xinds = -3:6 | ||
A = OffsetArray(Float64[f(x) for x in xinds], xinds) | ||
itpg = interpolate(A, BSpline(Linear())) | ||
@testset "ExtrapNon1" begin | ||
|
||
schemes = ( | ||
Flat, | ||
Line, | ||
Reflect, | ||
Periodic | ||
) | ||
f(x) = sin((x-3)*2pi/9 - 1) | ||
xinds = -3:6 | ||
A = OffsetArray(Float64[f(x) for x in xinds], xinds) | ||
itpg = interpolate(A, BSpline(Linear())) | ||
|
||
for etp in map(E -> extrapolate(itpg, E()), schemes), x in xinds | ||
@test parent(etp) === itpg | ||
@test @inferred(getindex(etp, x)) ≈ A[x] | ||
end | ||
schemes = ( | ||
Flat, | ||
Line, | ||
Reflect, | ||
Periodic | ||
) | ||
|
||
g(y) = (y/100)^3 | ||
yinds = 2:5 | ||
A = OffsetArray(Float64[f(x)*g(y) for x in xinds, y in yinds], xinds, yinds) | ||
itp2 = interpolate(A, BSpline(Linear())) | ||
for etp in map(E -> extrapolate(itpg, E()), schemes), x in xinds | ||
@test parent(etp) === itpg | ||
@test @inferred(getindex(etp, x)) ≈ A[x] | ||
end | ||
|
||
for (etp2,E) in map(E -> (extrapolate(itp2, E()), E), schemes) | ||
@test parent(etp2) === itp2 | ||
E == Periodic && continue # g isn't periodic | ||
for y in yinds, x in xinds | ||
@test @inferred(getindex(etp2, x, y)) ≈ A[x, y] | ||
g(y) = (y/100)^3 | ||
yinds = 2:5 | ||
A = OffsetArray(Float64[f(x)*g(y) for x in xinds, y in yinds], xinds, yinds) | ||
itp2 = interpolate(A, BSpline(Linear())) | ||
|
||
for (etp2,E) in map(E -> (extrapolate(itp2, E()), E), schemes) | ||
@test parent(etp2) === itp2 | ||
E == Periodic && continue # g isn't periodic | ||
for y in yinds, x in xinds | ||
@test @inferred(getindex(etp2, x, y)) ≈ A[x, y] | ||
end | ||
end | ||
end | ||
|
||
end |
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
Oops, something went wrong.