Skip to content

Commit eec6d38

Browse files
committed
get hessian tests passing
1 parent d033f0f commit eec6d38

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

src/b-splines/constant.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,36 @@ to `A[ceil(Int,x)]` without scaling.
6767
Constant
6868

6969
function positions(c::Constant{Previous}, ax, x) # discontinuity occurs at integer locations
70-
xm = floorbounds(x, ax)
70+
x_value = ForwardDiff.value(ForwardDiff.value(x))
71+
xm = floorbounds(x_value, ax)
7172
δx = x - xm
7273
fast_trunc(Int, xm), δx
7374
end
7475
function positions(c::Constant{Next}, ax, x) # discontinuity occurs at integer locations
75-
xm = ceilbounds(x, ax)
76+
x_value = ForwardDiff.value(ForwardDiff.value(x))
77+
xm = ceilbounds(x_value, ax)
7678
δx = x - xm
7779
fast_trunc(Int, xm), δx
7880
end
7981
function positions(c::Constant{Nearest}, ax, x) # discontinuity occurs at half-integer locations
80-
xm = roundbounds(x, ax)
82+
x_value = ForwardDiff.value(ForwardDiff.value(x))
83+
xm = roundbounds(x_value, ax)
8184
δx = x - xm
82-
fast_trunc(Int, xm), δx
85+
i = fast_trunc(Int, xm)
86+
i, δx
8387
end
8488

8589
function positions(c::Constant{Previous,Periodic{OnCell}}, ax, x)
90+
x_value = ForwardDiff.value(ForwardDiff.value(x))
8691
# We do not use floorbounds because we do not want to add a half at
8792
# the lowerbound to round up.
88-
xm = floor(x)
93+
xm = floor(x_value)
8994
δx = x - xm
9095
modrange(fast_trunc(Int, xm), ax), δx
9196
end
9297
function positions(c::Constant{Next,Periodic{OnCell}}, ax, x) # discontinuity occurs at integer locations
93-
xm = ceilbounds(x, ax)
98+
x_value = ForwardDiff.value(ForwardDiff.value(x))
99+
xm = ceilbounds(x_value, ax)
94100
δx = x - xm
95101
modrange(fast_trunc(Int, xm), ax), δx
96102
end

src/b-splines/indexing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
itpinfo(itp) = (tcollect(itpflag, itp), axes(itp))
44

55
@inline function (itp::BSplineInterpolation{T,N})(x::Vararg{Number,N}) where {T,N}
6-
@boundscheck (checkbounds(Bool, itp, ForwardDiff.value.(x)...) || Base.throw_boundserror(itp, x))
6+
@boundscheck (checkbounds(Bool, itp, ForwardDiff.value.(ForwardDiff.value.(x))...) || Base.throw_boundserror(itp, x))
77
wis = weightedindexes((value_weights,), itpinfo(itp)..., x)
88
InterpGetindex(itp)[wis...]
99
end

src/b-splines/linear.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ a piecewise linear function connecting each pair of neighboring data points.
4343
Linear
4444

4545
function positions(deg::Linear, ax::AbstractUnitRange{<:Integer}, x)
46-
x_value = ForwardDiff.value(x)
46+
x_value = ForwardDiff.value(ForwardDiff.value(x))
4747
f = floor(x_value)
4848
# When x == last(ax) we want to use the x-1, x pair
4949
f = ifelse(x_value == last(ax), f - oneunit(f), f)

src/monotonic/monotonic.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ function interpolate(
207207
end
208208

209209
function (itp::MonotonicInterpolation)(x::Number)
210-
@boundscheck (checkbounds(Bool, itp, x) || Base.throw_boundserror(itp, (x,)))
211-
k = searchsortedfirst(itp.knots, x)
210+
x_value = ForwardDiff.value(ForwardDiff.value(x))
211+
@boundscheck (checkbounds(Bool, itp, x_value) || Base.throw_boundserror(itp, (x_value,)))
212+
k = searchsortedfirst(itp.knots, x_value)
212213
if k > 1
213214
k -= 1
214215
end

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ using Interpolations
1111
const isci = get(ENV, "CI", "") in ("true", "True")
1212

1313
@testset "Interpolations" begin
14-
@test isempty(detect_ambiguities(Interpolations))
14+
@testset "method ambiguities" begin
15+
@test isempty(detect_ambiguities(Interpolations))
16+
end
1517

1618
include("core.jl")
1719
# Hermite interpolation tests

0 commit comments

Comments
 (0)