Skip to content

Commit e3325a2

Browse files
authored
Allow a tuple to be passed with scale, Fix #528, #535 (#534)
* Allow a tuple to be passed with scale * Remove tests for Julia 1.0 * Fix #535 warn * Add 1.6 tests, default constructors * Use approx in test
1 parent 0d29e77 commit e3325a2

File tree

13 files changed

+45
-4
lines changed

13 files changed

+45
-4
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
version:
16-
- '1.0'
1716
- '1.3'
17+
- '1.6'
1818
- '1'
1919
- 'nightly'
2020
os:

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Ratios = "0.3, 0.4"
2525
Requires = "1.1"
2626
StaticArrays = "0.12, 1"
2727
WoodburyMatrices = "0.4, 0.5"
28-
julia = "1"
28+
julia = "1.3"
2929

3030
[extras]
3131
ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4"

src/b-splines/b-splines.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct BSpline{D<:Degree} <: InterpolationType
2020
degree::D
2121
end
2222

23+
BSpline(::Type{D}) where D <: Degree = BSpline(D())
24+
2325
bsplinetype(::Type{BSpline{D}}) where {D<:Degree} = D
2426
bsplinetype(::BS) where {BS<:BSpline} = bsplinetype(BS)
2527

src/b-splines/constant.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Constant(args...) = Constant{Nearest}(args...)
4141
Constant{T}() where {T<:ConstantInterpType} = Constant{T,Throw{OnGrid}}(Throw(OnGrid()))
4242
Constant{T}(bc::BC) where {T<:ConstantInterpType,BC<:BoundaryCondition} = Constant{T,BC}(bc)
4343
Constant{T}(::Periodic{Nothing}) where {T<:ConstantInterpType} = Constant{T,Periodic{OnCell}}(Periodic(OnCell()))
44+
Constant(::Type{T}) where T <: ConstantInterpType = Constant{T}()
4445

4546
function Base.show(io::IO, deg::Constant)
4647
print(io, nameof(typeof(deg)), '{', typeof(deg).parameters[1], '}', '(')

src/b-splines/cubic.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ struct Cubic{BC<:BoundaryCondition} <: DegreeBC{3}
33
end
44

55
(deg::Cubic)(gt::GridType) = Cubic(deg.bc(gt))
6+
# Default constructor to match cubic_spline_interpolation
7+
Cubic() = Cubic(Line(OnGrid()))
68

79
"""
810
Cubic(bc::BoundaryCondition)

src/b-splines/quadratic.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
struct Quadratic{BC<:BoundaryCondition} <: DegreeBC{2}
22
bc::BC
33
end
4+
# Default constructor
5+
Quadratic() = Quadratic(Line(OnGrid()))
46
(deg::Quadratic)(gt::GridType) = Quadratic(deg.bc(gt))
57

68

src/monotonic/monotonic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function MonotonicInterpolation(::Type{TWeights}, it::TInterpolationType, knots:
154154
m::Vector{TCoeffs1}, c::Vector{TCoeffs2}, d::Vector{TCoeffs3}) where {TWeights, TCoeffs1, TCoeffs2, TCoeffs3, TEl, TInterpolationType<:MonotonicInterpolationType, TKnots<:AbstractVector{<:Number}}
155155

156156
isconcretetype(TInterpolationType) || error("The spline type must be a leaf type (was $TInterpolationType)")
157-
isconcretetype(tcoef(A)) || warn("For performance reasons, consider using an array of a concrete type (eltype(A) == $(eltype(A)))")
157+
isconcretetype(tcoef(A)) || @warn("For performance reasons, consider using an array of a concrete type (eltype(A) == $(eltype(A)))")
158158

159159
check_monotonic(knots, A)
160160

src/scaling/scaling.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function scale(itp::AbstractInterpolation{T,N,IT}, ranges::Vararg{AbstractRange,
2828
check_ranges(itpflag(itp), axes(itp), ranges)
2929
ScaledInterpolation{T,N,typeof(itp),IT,typeof(ranges)}(itp, ranges)
3030
end
31+
scale(itp::AbstractInterpolation{T,N,IT}, ranges::NTuple{N, <:AbstractRange}) where {T,N,IT} = scale(itp, ranges...)
3132

3233
function check_ranges(flags, axs, ranges)
3334
check_range(getfirst(flags), axs[1], ranges[1])

test/b-splines/constant.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
for T in (Nearest, Previous, Next)
1111
it = Constant{T}()
1212
@test it isa Constant{T}
13+
it = T |> Constant
14+
@test it isa Constant{T}
1315
end
1416
end
1517

test/b-splines/cubic.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
end
5151
end
5252

53+
# Test default constructor
54+
itp_type = Cubic |> BSpline
55+
itp = interpolate(1:5, itp_type)
56+
@test itp(1:0.5:5) 1:0.5:5
57+
5358
ix = 1:15
5459
k = length(ix) - 1
5560
f(x) = cos((x-1)*2pi/k)

0 commit comments

Comments
 (0)