Skip to content

Commit ac1db88

Browse files
committed
directly compute element type when possible
1 parent ee7b2e3 commit ac1db88

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/b-splines/b-splines.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ function BSplineInterpolation(::Type{TWeights}, A::AbstractArray{Tel,N}, ::IT, :
2525
for _ in 2:N
2626
c *= c
2727
end
28-
T = Base.promote_op(*, typeof(c), Tel)
29-
28+
if isempty(A)
29+
T = Base.promote_op(*, typeof(c), Tel)
30+
else
31+
T = typeof(c*first(A))
32+
end
3033
BSplineInterpolation{T,N,typeof(A),IT,GT,pad}(A)
3134
end
3235

src/gridded/gridded.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ function GriddedInterpolation(::Type{TWeights}, knots::NTuple{N,GridIndex}, A::A
2828
for _ in 2:N
2929
c *= c
3030
end
31-
T = Base.promote_op(*, typeof(c), TCoefs)
32-
31+
if isempty(A)
32+
T = Base.promote_op(*, typeof(c), Tel)
33+
else
34+
T = typeof(c*first(A))
35+
end
3336
GriddedInterpolation{T,N,TCoefs,IT,typeof(knts),pad}(knts, A)
3437
end
3538

0 commit comments

Comments
 (0)