Skip to content

Commit 01835b0

Browse files
rdeitstimholy
authored andcommitted
move promote_type call inside the generated function body (#208)
1 parent 93a2531 commit 01835b0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ julia:
66
matrix:
77
allow_failures:
88
- julia: nightly
9+
after_success:
10+
# push coverage results to Coveralls
11+
- julia -e 'cd(Pkg.dir("WebIO")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
12+
# push coverage results to Codecov
13+
- julia -e 'cd(Pkg.dir("WebIO")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'

src/b-splines/indexing.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ end
108108
for R in [:Real, :Any]
109109
@eval @generated function gradient(itp::AbstractInterpolation{T,N}, xs::$R...) where {T,N}
110110
n = count_interp_dims(itp, N)
111-
Tg = promote_type(T, [x <: AbstractArray ? eltype(x) : x for x in xs]...)
112111
xargs = [:(xs[$d]) for d in 1:length(xs)]
113-
:(gradient!(Array{$Tg, 1}($n), itp, $(xargs...)))
112+
quote
113+
Tg = $(Expr(:call, :promote_type, T, [x <: AbstractArray ? eltype(x) : x for x in xs]...))
114+
gradient!(Array{Tg, 1}($n), itp, $(xargs...))
115+
end
114116
end
115117
end
116118

@@ -158,9 +160,11 @@ end
158160

159161
@generated function hessian(itp::AbstractInterpolation{T,N}, xs...) where {T,N}
160162
n = count_interp_dims(itp,N)
161-
TH = promote_type(T, [x <: AbstractArray ? eltype(x) : x for x in xs]...)
162163
xargs = [:(xs[$d]) for d in 1:length(xs)]
163-
:(hessian!(Array{TH, 2}($n,$n), itp, $(xargs...)))
164+
quote
165+
TH = $(Expr(:call, :promote_type, T, [x <: AbstractArray ? eltype(x) : x for x in xs]...))
166+
hessian!(Array{TH, 2}($n,$n), itp, $(xargs...))
167+
end
164168
end
165169

166170
hessian1(itp::AbstractInterpolation{T,1}, x) where {T} = hessian(itp, x)[1,1]

0 commit comments

Comments
 (0)