Skip to content

Commit 51ad6a8

Browse files
committed
Error if extrapolate-filling with a type, rather than value (fixes #232)
1 parent 34a50c7 commit 51ad6a8

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/extrapolation/filled.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ function FilledExtrapolation(itp::AbstractInterpolation{T,N,IT}, fillvalue) wher
88
FilledExtrapolation{Te,N,typeof(itp),IT,typeof(fillvalue)}(itp, fillvalue)
99
end
1010

11+
@noinline FilledExtrapolation(itp::AbstractInterpolation{T,N,IT}, ::Type{F}) where {T,N,IT,F} =
12+
throw(ArgumentError("cannot create a filled extrapolation with a type $F, use a value of this type instead (e.g., $F(0))"))
13+
@noinline FilledExtrapolation(itp::AbstractInterpolation{T,N,IT}, ::Type{F}) where {T,N,IT,F<:BoundaryCondition} =
14+
throw(ArgumentError("cannot create a filled extrapolation with a type $F, use a value of this type instead (e.g., $F())"))
15+
1116
Base.parent(A::FilledExtrapolation) = A.itp
1217
etpflag(A::FilledExtrapolation) = A.fillvalue
1318
itpflag(A::FilledExtrapolation) = itpflag(A.itp)

test/extrapolation/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ using Test
9191
@test itpe(10.1, 1) 10.1
9292
@test_throws BoundsError itpe(9.9, 0)
9393

94+
# Issue #232
95+
targeterr = ArgumentError("cannot create a filled extrapolation with a type Line, use a value of this type instead (e.g., Line())")
96+
@test_throws targeterr extrapolate(itp, Line)
97+
9498
include("type-stability.jl")
9599
include("non1.jl")
96100
end

0 commit comments

Comments
 (0)