Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Interpolations"
uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
version = "0.16.1"
version = "0.16.2"

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

[targets]
test = ["OffsetArrays", "Unitful", "SharedArrays", "ForwardDiff", "LinearAlgebra", "DualNumbers", "Random", "Pkg", "Test", "Zygote", "ColorVectorSpace"]
test = ["ColorVectorSpace", "DualNumbers", "JLArrays", "ForwardDiff", "Test", "Unitful", "Zygote"]
6 changes: 1 addition & 5 deletions ext/InterpolationsUnitfulExt.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
module InterpolationsUnitfulExt

if !isdefined(Base, :get_extension)
import ..Unitful, ..Interpolations
else
import Unitful, Interpolations
end
import Unitful, Interpolations

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

Expand Down
14 changes: 1 addition & 13 deletions src/Interpolations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,6 @@ include("lanczos/lanczos_opencv.jl")
include("iterate.jl")
include("chainrules/chainrules.jl")
include("hermite/cubic.jl")
if VERSION >= v"1.6"
include("gpu_support.jl")
end

if !isdefined(Base, :get_extension)
using Requires
end

@static if !isdefined(Base, :get_extension)
function __init__()
@require Unitful="1986cc42-f94f-5a68-af5c-568840ba703d" include("../ext/InterpolationsUnitfulExt.jl")
end
end
include("gpu_support.jl")

end # module
8 changes: 2 additions & 6 deletions src/b-splines/b-splines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,8 @@ function interpolate!(A::AbstractArray, it::IT, λ::Real, k::Int) where {IT<:Dim
interpolate!(tweight(A), A, it, λ, k)
end

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

include("constant.jl")
include("linear.jl")
Expand Down
18 changes: 3 additions & 15 deletions test/chainrules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,20 @@ using Zygote: Zygote

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

if VERSION ≥ v"1.3"
@test Zygote.gradient(itp, 1) == Tuple(Interpolations.gradient(itp, 1))
else
@test_skip Zygote.gradient(itp, 1) == Tuple(Interpolations.gradient(itp, 1))
end
@test Zygote.gradient(itp, 1) == Tuple(Interpolations.gradient(itp, 1))

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

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

if VERSION ≥ v"1.3"
@test Zygote.gradient(itp2,1,2) == Tuple(Interpolations.gradient(itp2,1,2))
else
@test_skip Zygote.gradient(itp2,1,2) == Tuple(Interpolations.gradient(itp2,1,2))
end
@test Zygote.gradient(itp2,1,2) == Tuple(Interpolations.gradient(itp2,1,2))

# Matrix-valued
y=[[[0 0; 0 0]] [[1 2; 0 0]];
[[0 0; 3 4]] [[1 2; 3 4]]]
itp_m = interpolate(y, BSpline(Linear()))
if VERSION ≥ v"1.3"
@test Zygote.jacobian(itp_m, 1,1) == Tuple((x->[x...]).(Interpolations.gradient(itp_m, 1,1)))
else
@test_skip Zygote.jacobian(itp_m, 1,1) == Tuple((x->[x...]).(Interpolations.gradient(itp_m, 1,1)))
end
@test Zygote.jacobian(itp_m, 1,1) == Tuple((x->[x...]).(Interpolations.gradient(itp_m, 1,1)))

end
42 changes: 11 additions & 31 deletions test/iterate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,17 @@ macro test_knots(itersym, type, expect...)
IterEqCheck = :( kiter ≈ kref )
end

# Check Type-stability if v > 1.2
@static if VERSION >= v"1.2"
# Check Type-stability using inferred
type_stability_checks = quote
@testset "type stability" begin
iteratetype = Union{Nothing, knotType}
y = @inferred iteratetype iterate($itersym)
if y !== nothing
@test_nowarn @inferred iteratetype iterate($itersym, y[2])
end
isBounded && @test_nowarn @inferred Integer length($itersym)
@test_nowarn @inferred Type eltype($itersym)
# Check Type-stability using inferred
type_stability_checks = quote
@testset "type stability" begin
iteratetype = Union{Nothing, knotType}
y = @inferred iteratetype iterate($itersym)
if y !== nothing
@test_nowarn @inferred iteratetype iterate($itersym, y[2])
end
isBounded && @test_nowarn @inferred Integer length($itersym)
@test_nowarn @inferred Type eltype($itersym)
end
else
# Skip Type-stability checks as @inferred AllowedTypes is Undefined
type_stability_checks = :()
end

# Build test_knots tests
Expand Down Expand Up @@ -159,28 +153,14 @@ knot_ref(seq, ::Interpolations.BoundaryCondition) = seq
function knot_ref(seq, ::Periodic)
Δ = diff(seq)
iter = Iterators.flatten((first(seq), Iterators.cycle(Δ)))
@static if VERSION >= v"1.5"
Iterators.accumulate(+, iter)
else
# Generate 200 samples (2x factor on testing done by @test_knots)
# Then wrap with cycle to get IteratorSize === IsInfinite
# TODO: Remove when Julia v1 is no longer supported
ref = Iterators.take(iter, 200) |> collect |> cumsum |> Iterators.cycle
end
Iterators.accumulate(+, iter)
end

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

@testset "knot_ref" begin
Expand Down
6 changes: 1 addition & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,5 @@ const isci = get(ENV, "CI", "") in ("true", "True")
# Chain rules interaction
include("chainrules.jl")

if VERSION >= v"1.6"
import Pkg
Pkg.add("JLArrays")
include("gpu_support.jl")
end
include("gpu_support.jl")
end
Loading