Skip to content

Commit 60862fe

Browse files
committed
Don't pretend to be more generic than is possible
1 parent eda9f10 commit 60862fe

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/Interpolations.jl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,20 @@ const Natural = Line
7777

7878
Base.IndexStyle(::Type{<:AbstractInterpolation}) = IndexCartesian()
7979

80-
size(itp::AbstractInterpolation) = map(length, itp.parentaxes)
8180
size(exp::AbstractExtrapolation) = size(exp.itp)
82-
axes(itp::AbstractInterpolation) = itp.parentaxes
8381
axes(exp::AbstractExtrapolation) = axes(exp.itp)
8482

85-
bounds(itp::AbstractInterpolation) = map(twotuple, lbounds(itp), ubounds(itp))
8683
twotuple(r::AbstractUnitRange) = (first(r), last(r))
8784
twotuple(x, y) = (x, y)
85+
bounds(itp::AbstractInterpolation) = map(twotuple, lbounds(itp), ubounds(itp))
8886
bounds(itp::AbstractInterpolation, d) = bounds(itp)[d]
89-
lbounds(itp::AbstractInterpolation) = _lbounds(itp.parentaxes, itpflag(itp), gridflag(itp))
90-
ubounds(itp::AbstractInterpolation) = _ubounds(itp.parentaxes, itpflag(itp), gridflag(itp))
91-
_lbounds(axs::NTuple{N,Any}, itp, gt) where N = ntuple(d->lbound(axs[d], iextract(itp,d), iextract(gt,d)), Val(N))
92-
_ubounds(axs::NTuple{N,Any}, itp, gt) where N = ntuple(d->ubound(axs[d], iextract(itp,d), iextract(gt,d)), Val(N))
9387

9488
itptype(::Type{AbstractInterpolation{T,N,IT,GT}}) where {T,N,IT<:DimSpec{InterpolationType},GT<:DimSpec{GridType}} = IT
9589
itptype(::Type{ITP}) where {ITP<:AbstractInterpolation} = itptype(supertype(ITP))
9690
itptype(itp::AbstractInterpolation) = itptype(typeof(itp))
97-
itpflag(itp::AbstractInterpolation) = itp.it
9891
gridtype(::Type{AbstractInterpolation{T,N,IT,GT}}) where {T,N,IT<:DimSpec{InterpolationType},GT<:DimSpec{GridType}} = GT
9992
gridtype(::Type{ITP}) where {ITP<:AbstractInterpolation} = gridtype(supertype(ITP))
10093
gridtype(itp::AbstractInterpolation) = gridtype(typeof(itp))
101-
gridflag(itp::AbstractInterpolation) = itp.gt
10294
ndims(::Type{AbstractInterpolation{T,N,IT,GT}}) where {T,N,IT<:DimSpec{InterpolationType},GT<:DimSpec{GridType}} = N
10395
ndims(::Type{ITP}) where {ITP<:AbstractInterpolation} = ndims(supertype(ITP))
10496
ndims(itp::AbstractInterpolation) = ndims(typeof(itp))
@@ -184,7 +176,7 @@ Base.to_index(::AbstractInterpolation, x::Number) = x
184176

185177
# Commented out because you can't add methods to an abstract type.
186178
# @inline function (itp::AbstractInterpolation)(x::Vararg{UnexpandedIndexTypes})
187-
# itp(to_indices(itp, x))
179+
# itp(to_indices(itp, x)...)
188180
# end
189181
function gradient(itp::AbstractInterpolation, x::Vararg{UnexpandedIndexTypes})
190182
gradient(itp, to_indices(itp, x)...)

src/b-splines/b-splines.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ coefficients(itp::BSplineInterpolation) = itp.coefs
4545
interpdegree(itp::BSplineInterpolation) = interpdegree(itpflag(itp))
4646
interpdegree(::BSpline{T}) where T = T()
4747
interpdegree(it::Tuple{Vararg{Union{BSpline,NoInterp},N}}) where N = interpdegree.(it)
48+
itpflag(itp::BSplineInterpolation) = itp.it
49+
gridflag(itp::BSplineInterpolation) = itp.gt
50+
51+
size(itp::BSplineInterpolation) = map(length, itp.parentaxes)
52+
axes(itp::BSplineInterpolation) = itp.parentaxes
53+
54+
lbounds(itp::BSplineInterpolation) = _lbounds(itp.parentaxes, itpflag(itp), gridflag(itp))
55+
ubounds(itp::BSplineInterpolation) = _ubounds(itp.parentaxes, itpflag(itp), gridflag(itp))
56+
_lbounds(axs::NTuple{N,Any}, itp, gt) where N = ntuple(d->lbound(axs[d], iextract(itp,d), iextract(gt,d)), Val(N))
57+
_ubounds(axs::NTuple{N,Any}, itp, gt) where N = ntuple(d->ubound(axs[d], iextract(itp,d), iextract(gt,d)), Val(N))
4858

4959
# The unpadded defaults
5060
lbound(ax, ::BSpline, ::OnCell) = first(ax) - 0.5

src/b-splines/indexing.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
@boundscheck (checkbounds(Bool, itp, x...) || Base.throw_boundserror(itp, x))
55
expand_value(itp, x)
66
end
7-
@inline function (itp::BSplineInterpolation{T,1})(x::Integer, y::Integer) where T
8-
@boundscheck (y == 1 || Base.throw_boundserror(itp, (x,y)))
9-
expand_value(itp, (x,))
10-
end
7+
# @inline function (itp::BSplineInterpolation{T,1})(x::Integer, y::Integer) where T
8+
# @boundscheck (y == 1 || Base.throw_boundserror(itp, (x,y)))
9+
# expand_value(itp, (x,))
10+
# end
1111

1212
@inline function gradient(itp::BSplineInterpolation{T,N}, x::Vararg{Number,N}) where {T,N}
1313
@boundscheck checkbounds(Bool, itp, x...) || Base.throw_boundserror(itp, x)

0 commit comments

Comments
 (0)