Skip to content

Commit b8632ba

Browse files
author
Tomas Lycken
committed
Update constant extrap @nref usage
1 parent b9a8bd9 commit b8632ba

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

src/extrapolation/constant.jl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@ ConstantExtrapolation{T,ITP,IT,GT}(::Type{T}, N, itp::ITP, ::Type{IT}, ::Type{GT
77
extrapolate{T,N,IT,GT}(itp::AbstractInterpolation{T,N,IT,GT}, ::Type{Flat}) =
88
ConstantExtrapolation(T,N,itp,IT,GT)
99

10-
function extrap_prep{T,ITP,IT}(etp::Type{ConstantExtrapolation{T,1,ITP,IT,OnGrid}}, x)
11-
:(x = clamp(x, 1, size(etp,1)))
12-
end
13-
function extrap_prep{T,ITP,IT}(etp::Type{ConstantExtrapolation{T,1,ITP,IT,OnCell}}, x)
14-
:(x = clamp(x, .5, size(etp,1)+.5))
15-
end
1610
function extrap_prep{T,N,ITP,IT}(etp::Type{ConstantExtrapolation{T,N,ITP,IT,OnGrid}}, xs...)
17-
:(@nexprs $N d->(xs[d] = clamp(xs[d], 1, size(etp,d))))
11+
:(@nexprs $N d->(x_d = clamp(xs[d], one($xs[d]), size(etp,d))))
1812
end
1913
function extrap_prep{T,N,ITP,IT}(etp::Type{ConstantExtrapolation{T,N,ITP,IT,OnCell}}, xs...)
20-
:(@nexprs $N d->(xs[d] = clamp(xs[d], .5, size(etp,d)+.5)))
14+
:(@nexprs $N d->(x_d = clamp(xs[d], 1//2, size(etp,d)+1//2)))
2115
end

src/extrapolation/periodic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ extrapolate{T,N,IT,GT}(itp::AbstractInterpolation{T,N,IT,GT}, ::Type{Periodic})
88
PeriodicExtrapolation(T,N,itp,IT,GT)
99

1010
function extrap_prep{T,N,ITP,IT,GT}(etp::Type{PeriodicExtrapolation{T,N,ITP,IT,GT}}, xs...)
11-
:(@nexprs $N d->(; x_d = mod(xs[d]-one($xs[d]), size(etp.itp,d)-one($xs[d]))+one($xs[d])))
11+
:(@nexprs $N d->(x_d = mod(xs[d]-one($xs[d]), size(etp.itp,d)-one($xs[d]))+one($xs[d])))
1212
end

0 commit comments

Comments
 (0)