Skip to content

Commit fca05e8

Browse files
taylormcdtimholy
authored andcommitted
make compatible with ForwardDiff at lower bound of extrapolation object (#336)
1 parent 9285dd1 commit fca05e8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/extrapolation/extrapolation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function inbounds_index((flagl,flagu)::Tuple{Nothing,Throw}, (l,u), x, etp, xN)
123123
end
124124

125125
function inbounds_index((flagl,flagu)::Tuple{Union{Flat,Line},Flag}, (l,u), x, etp, xN)
126-
inbounds_index((nothing,flagu), (l,u), maxp(x,l), etp, xN)
126+
inbounds_index((nothing,flagu), (l,u), maxp(l,x), etp, xN)
127127
end
128128
function inbounds_index((flagl,flagu)::Tuple{Nothing,Union{Flat,Line}}, (l,u), x, etp, xN)
129129
minp(x,u)

test/issues/runtests.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,21 @@ using Interpolations, Test, ForwardDiff
129129
j = ForwardDiff.gradient(itp_test, [2.0])
130130
@test j Interpolations.gradient(build_itp(), 2.0)
131131
end
132+
133+
@testset "issue 335" begin
134+
function build_itp()
135+
A_x = 1:5
136+
A = A_x
137+
knots = (A_x,)
138+
LinearInterpolation(knots, A, extrapolation_bc=Line())
139+
end
140+
function itp_test(x::AbstractVector)
141+
itp = build_itp()
142+
return itp(x...)
143+
end
144+
145+
@test ForwardDiff.gradient(itp_test, [1.0]) Interpolations.gradient(build_itp(), 1.0)
146+
@test ForwardDiff.gradient(itp_test, [5.0]) Interpolations.gradient(build_itp(), 5.0)
147+
end
148+
132149
end

0 commit comments

Comments
 (0)