From 72790c8c1c0eb5faaa25b8c2491fdac087a14a3d Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Sat, 13 Jul 2024 19:08:59 +0200 Subject: [PATCH] Move SparseArrays to weakdeps --- Project.toml | 4 ++-- ext/DataInterpolationsChainRulesCoreExt.jl | 3 ++- src/DataInterpolations.jl | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index d2b21cef..b3bdcfa1 100644 --- a/Project.toml +++ b/Project.toml @@ -10,16 +10,16 @@ PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" ReadOnlyArrays = "988b38a3-91fc-5605-94a2-ee2116b3bd83" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" -SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [weakdeps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" Optim = "429524aa-4258-5aef-a3af-852621145aeb" RegularizationTools = "29dad682-9a27-4bc3-9c72-016788665182" +SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" [extensions] -DataInterpolationsChainRulesCoreExt = "ChainRulesCore" +DataInterpolationsChainRulesCoreExt = ["ChainRulesCore", "SparseArrays"] DataInterpolationsOptimExt = "Optim" DataInterpolationsRegularizationToolsExt = "RegularizationTools" DataInterpolationsSymbolicsExt = "Symbolics" diff --git a/ext/DataInterpolationsChainRulesCoreExt.jl b/ext/DataInterpolationsChainRulesCoreExt.jl index 30d3fe09..37613347 100644 --- a/ext/DataInterpolationsChainRulesCoreExt.jl +++ b/ext/DataInterpolationsChainRulesCoreExt.jl @@ -92,7 +92,8 @@ function ChainRulesCore.rrule(::Type{QuadraticSplineParameterCache}, u, t) n = length(u) Δt = diff(t) - diagonal_main = [zero(eltype(Δt)), 2 ./ Δt...] + diagonal_main = 2 ./ Δt + pushfirst!(diagonal_main, zero(eltype(diagonal_main))) diagonal_down = -diagonal_main[2:end] diagonal_up = zero(diagonal_down) ∂d_∂u = Tridiagonal(diagonal_down, diagonal_main, diagonal_up) diff --git a/src/DataInterpolations.jl b/src/DataInterpolations.jl index d5c31598..c86a6579 100644 --- a/src/DataInterpolations.jl +++ b/src/DataInterpolations.jl @@ -8,7 +8,6 @@ using LinearAlgebra, RecipesBase using PrettyTables using ForwardDiff using ReadOnlyArrays -using SparseArrays # Only used in DataInterpolationsChainRulesCoreExt.jl, but otherwise Aqua complains import FindFirstFunctions: searchsortedfirstcorrelated, searchsortedlastcorrelated, bracketstrictlymontonic