Skip to content

Commit 4d35396

Browse files
authored
Remove Requires and branches for unsupported VERSIONs (#632)
1 parent 078a1b1 commit 4d35396

File tree

7 files changed

+23
-84
lines changed

7 files changed

+23
-84
lines changed

Project.toml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Interpolations"
22
uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
3-
version = "0.16.1"
3+
version = "0.16.2"
44

55
[deps]
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -10,7 +10,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1010
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
1111
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1212
Ratios = "c84ed2f1-dad5-54f0-aa8e-dbefe2724439"
13-
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1413
SharedArrays = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
1514
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1615
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
@@ -29,9 +28,9 @@ Adapt = "2, 3, 4.0"
2928
AxisAlgorithms = "0.3, 1"
3029
ChainRulesCore = "0.10, 1.0, 1.2, 1.3"
3130
ForwardDiff = "0.10, 1.0"
31+
JLArrays = "0.2"
3232
OffsetArrays = "0.10, 0.11, 1.0.1"
3333
Ratios = "0.3, 0.4"
34-
Requires = "1.1"
3534
StaticArrays = "0.12, 1"
3635
Unitful = "1"
3736
WoodburyMatrices = "0.4, 0.5, 1.0"
@@ -40,15 +39,11 @@ julia = "1.9"
4039
[extras]
4140
ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4"
4241
DualNumbers = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74"
42+
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
4343
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
44-
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
45-
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
46-
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
47-
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
48-
SharedArrays = "1a1011a3-84de-559e-8e89-a11a2f7dc383"
4944
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5045
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
5146
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
5247

5348
[targets]
54-
test = ["OffsetArrays", "Unitful", "SharedArrays", "ForwardDiff", "LinearAlgebra", "DualNumbers", "Random", "Pkg", "Test", "Zygote", "ColorVectorSpace"]
49+
test = ["ColorVectorSpace", "DualNumbers", "JLArrays", "ForwardDiff", "Test", "Unitful", "Zygote"]

ext/InterpolationsUnitfulExt.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
module InterpolationsUnitfulExt
22

3-
if !isdefined(Base, :get_extension)
4-
import ..Unitful, ..Interpolations
5-
else
6-
import Unitful, Interpolations
7-
end
3+
import Unitful, Interpolations
84

95
Interpolations.tweight(A::AbstractArray{T}) where T <: Unitful.Quantity = Interpolations.tweight(Unitful.ustrip(A))
106

src/Interpolations.jl

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -473,18 +473,6 @@ include("lanczos/lanczos_opencv.jl")
473473
include("iterate.jl")
474474
include("chainrules/chainrules.jl")
475475
include("hermite/cubic.jl")
476-
if VERSION >= v"1.6"
477-
include("gpu_support.jl")
478-
end
479-
480-
if !isdefined(Base, :get_extension)
481-
using Requires
482-
end
483-
484-
@static if !isdefined(Base, :get_extension)
485-
function __init__()
486-
@require Unitful="1986cc42-f94f-5a68-af5c-568840ba703d" include("../ext/InterpolationsUnitfulExt.jl")
487-
end
488-
end
476+
include("gpu_support.jl")
489477

490478
end # module

src/b-splines/b-splines.jl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,8 @@ function interpolate!(A::AbstractArray, it::IT, λ::Real, k::Int) where {IT<:Dim
253253
interpolate!(tweight(A), A, it, λ, k)
254254
end
255255

256-
if VERSION >= v"1.7.0-beta1"
257-
# https://github.com/JuliaLang/julia/pull/40623
258-
lut!(dl, d, du) = lu!(Tridiagonal(dl, d, du), NoPivot())
259-
else
260-
lut!(dl, d, du) = lu!(Tridiagonal(dl, d, du), Val(false))
261-
end
256+
# https://github.com/JuliaLang/julia/pull/40623
257+
lut!(dl, d, du) = lu!(Tridiagonal(dl, d, du), NoPivot())
262258

263259
include("constant.jl")
264260
include("linear.jl")

test/chainrules.jl

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,20 @@ using Zygote: Zygote
88

99
itp = interpolate(y,BSpline(Linear()))
1010

11-
if VERSION v"1.3"
12-
@test Zygote.gradient(itp, 1) == Tuple(Interpolations.gradient(itp, 1))
13-
else
14-
@test_skip Zygote.gradient(itp, 1) == Tuple(Interpolations.gradient(itp, 1))
15-
end
11+
@test Zygote.gradient(itp, 1) == Tuple(Interpolations.gradient(itp, 1))
1612

1713
# 2D example
1814
x2 = [i*j for i=1:5, j=1:5]
1915
y2 = sin.(x2)
2016

2117
itp2 = interpolate(y2, BSpline(Cubic(Line(OnGrid()))))
2218

23-
if VERSION v"1.3"
24-
@test Zygote.gradient(itp2,1,2) == Tuple(Interpolations.gradient(itp2,1,2))
25-
else
26-
@test_skip Zygote.gradient(itp2,1,2) == Tuple(Interpolations.gradient(itp2,1,2))
27-
end
19+
@test Zygote.gradient(itp2,1,2) == Tuple(Interpolations.gradient(itp2,1,2))
2820

2921
# Matrix-valued
3022
y=[[[0 0; 0 0]] [[1 2; 0 0]];
3123
[[0 0; 3 4]] [[1 2; 3 4]]]
3224
itp_m = interpolate(y, BSpline(Linear()))
33-
if VERSION v"1.3"
34-
@test Zygote.jacobian(itp_m, 1,1) == Tuple((x->[x...]).(Interpolations.gradient(itp_m, 1,1)))
35-
else
36-
@test_skip Zygote.jacobian(itp_m, 1,1) == Tuple((x->[x...]).(Interpolations.gradient(itp_m, 1,1)))
37-
end
25+
@test Zygote.jacobian(itp_m, 1,1) == Tuple((x->[x...]).(Interpolations.gradient(itp_m, 1,1)))
3826

3927
end

test/iterate.jl

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,17 @@ macro test_knots(itersym, type, expect...)
4444
IterEqCheck = :( kiter kref )
4545
end
4646

47-
# Check Type-stability if v > 1.2
48-
@static if VERSION >= v"1.2"
49-
# Check Type-stability using inferred
50-
type_stability_checks = quote
51-
@testset "type stability" begin
52-
iteratetype = Union{Nothing, knotType}
53-
y = @inferred iteratetype iterate($itersym)
54-
if y !== nothing
55-
@test_nowarn @inferred iteratetype iterate($itersym, y[2])
56-
end
57-
isBounded && @test_nowarn @inferred Integer length($itersym)
58-
@test_nowarn @inferred Type eltype($itersym)
47+
# Check Type-stability using inferred
48+
type_stability_checks = quote
49+
@testset "type stability" begin
50+
iteratetype = Union{Nothing, knotType}
51+
y = @inferred iteratetype iterate($itersym)
52+
if y !== nothing
53+
@test_nowarn @inferred iteratetype iterate($itersym, y[2])
5954
end
55+
isBounded && @test_nowarn @inferred Integer length($itersym)
56+
@test_nowarn @inferred Type eltype($itersym)
6057
end
61-
else
62-
# Skip Type-stability checks as @inferred AllowedTypes is Undefined
63-
type_stability_checks = :()
6458
end
6559

6660
# Build test_knots tests
@@ -159,28 +153,14 @@ knot_ref(seq, ::Interpolations.BoundaryCondition) = seq
159153
function knot_ref(seq, ::Periodic)
160154
Δ = diff(seq)
161155
iter = Iterators.flatten((first(seq), Iterators.cycle(Δ)))
162-
@static if VERSION >= v"1.5"
163-
Iterators.accumulate(+, iter)
164-
else
165-
# Generate 200 samples (2x factor on testing done by @test_knots)
166-
# Then wrap with cycle to get IteratorSize === IsInfinite
167-
# TODO: Remove when Julia v1 is no longer supported
168-
ref = Iterators.take(iter, 200) |> collect |> cumsum |> Iterators.cycle
169-
end
156+
Iterators.accumulate(+, iter)
170157
end
171158

172159
function knot_ref(seq, ::Reflect)
173160
Δ = diff(seq)
174161
Δ = vcat(Δ, reverse(Δ))
175162
iter = Iterators.flatten((first(seq), Iterators.cycle(Δ)))
176-
@static if VERSION >= v"1.5"
177-
Iterators.accumulate(+, iter)
178-
else
179-
# Generate 200 samples (2x factor on testing done by @test_knots)
180-
# Then wrap with cycle to get IteratorSize === IsInfinite
181-
# TODO: Remove when Julia v1 is no longer supported
182-
ref = Iterators.take(iter, 200) |> collect |> cumsum |> Iterators.cycle
183-
end
163+
Iterators.accumulate(+, iter)
184164
end
185165

186166
@testset "knot_ref" begin

test/runtests.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,5 @@ const isci = get(ENV, "CI", "") in ("true", "True")
5858
# Chain rules interaction
5959
include("chainrules.jl")
6060

61-
if VERSION >= v"1.6"
62-
import Pkg
63-
Pkg.add("JLArrays")
64-
include("gpu_support.jl")
65-
end
61+
include("gpu_support.jl")
6662
end

0 commit comments

Comments
 (0)