Skip to content

Commit 0f31ad3

Browse files
Tomas LyckenTomas Lycken
authored andcommitted
Fix disambiguation error in julia 0.5
1 parent ff8c774 commit 0f31ad3

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/b-splines/indexing.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ end
9898
:(gradient!(g, itp, $(args...)))
9999
end
100100

101-
@generated function gradient{T,N}(itp::AbstractInterpolation{T,N}, xs...)
102-
n = count_interp_dims(itp, N)
103-
Tg = promote_type(T, [x <: AbstractArray ? eltype(x) : x for x in xs]...)
104-
xargs = [:(xs[$d]) for d in 1:length(xs)]
105-
:(gradient!(Array($Tg,$n), itp, $(xargs...)))
101+
# @eval uglyness required for disambiguation with method in Base
102+
for R in [:Real, :Any]
103+
@eval @generated function gradient{T,N}(itp::AbstractInterpolation{T,N}, xs::$R...)
104+
n = count_interp_dims(itp, N)
105+
Tg = promote_type(T, [x <: AbstractArray ? eltype(x) : x for x in xs]...)
106+
xargs = [:(xs[$d]) for d in 1:length(xs)]
107+
:(gradient!(Array($Tg,$n), itp, $(xargs...)))
108+
end
106109
end
107110

108111
gradient1{T}(itp::AbstractInterpolation{T,1}, x) = gradient(itp, x)[1]

src/scaling/scaling.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ coordlookup(i::Bool, r::Range, x) = i ? coordlookup(r, x) : convert(typeof(coord
6868
basetype{T,N,ITPT,IT,GT,RT}(::Type{ScaledInterpolation{T,N,ITPT,IT,GT,RT}}) = ITPT
6969
basetype(sitp::ScaledInterpolation) = basetype(typeof(sitp))
7070

71-
gradient{T,N,ITPT,IT<:DimSpec}(sitp::ScaledInterpolation{T,N,ITPT,IT}, xs::Number...) = gradient!(Array(T,count_interp_dims(IT,N)), sitp, xs...)
71+
# @eval uglyness required for disambiguation with method in b-splies/indexing.jl
72+
# also, GT is only specified to avoid disambiguation warnings on julia 0.4
73+
gradient{T,N,ITPT,IT<:DimSpec{InterpolationType}}(sitp::ScaledInterpolation{T,N,ITPT,IT}, xs::Real...) = gradient!(Array(T,count_interp_dims(IT,N)), sitp, xs...)
74+
gradient{T,N,ITPT,IT<:DimSpec{InterpolationType}}(sitp::ScaledInterpolation{T,N,ITPT,IT}, xs...) = gradient!(Array(T,count_interp_dims(IT,N)), sitp, xs...)
75+
7276
@generated function gradient!{T,N,ITPT,IT}(g, sitp::ScaledInterpolation{T,N,ITPT,IT}, xs::Number...)
7377
ndims(g) == 1 || throw(DimensionMismatch("g must be a vector (but had $(ndims(g)) dimensions)"))
7478
length(xs) == N || throw(DimensionMismatch("Must index into $N-dimensional scaled interpolation object with exactly $N indices (you used $(length(xs)))"))

0 commit comments

Comments
 (0)