Skip to content

Move sparsedifftools dep to an extension #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
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
11 changes: 8 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MultiScaleArrays"
uuid = "f9640e96-87f6-5992-9c3b-0743c6a49ffa"
authors = ["Chris Rackauckas <[email protected]>"]
version = "1.13.0"
version = "1.14.0"

[deps]
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
Expand All @@ -11,10 +11,15 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"

[weakdeps]
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"

[extensions]
MultiScaleArraysSparseDiffToolsExt = "SparseDiffTools"

[compat]
DiffEqBase = "6.5"
FiniteDiff = "2.3"
Expand All @@ -24,7 +29,7 @@ RecursiveArrayTools = "1,2,3"
SparseDiffTools = "1.6, 2"
Statistics = "1"
StochasticDiffEq = "6.13"
julia = "1.6"
julia = "1.10"

[extras]
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Expand Down
35 changes: 35 additions & 0 deletions ext/MultiScaleArraysSparseDiffToolsExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module MultiScaleArraysSparseDiffToolsExt

using MultiScaleArrays, SparseDiffTools

function MultiScaleArrays.add_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x,
node...)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
nothing
end

function MultiScaleArrays.add_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
nothing
end

function MultiScaleArrays.remove_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x,
node...)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
nothing
end

function MultiScaleArrays.remove_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
nothing
end

end
2 changes: 1 addition & 1 deletion src/MultiScaleArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ abstract type AbstractMultiScaleArrayLeaf{B} <: AbstractMultiScaleArray{B} end
abstract type AbstractMultiScaleArrayHead{B} <: AbstractMultiScaleArray{B} end

using DiffEqBase, Statistics, LinearAlgebra, FiniteDiff
import OrdinaryDiffEq, StochasticDiffEq, ForwardDiff, SparseDiffTools
import OrdinaryDiffEq, StochasticDiffEq, ForwardDiff

Base.show(io::IO, x::AbstractMultiScaleArray) = invoke(show, Tuple{IO, Any}, io, x)
Base.show(io::IO, ::MIME"text/plain", x::AbstractMultiScaleArray) = show(io, x)
Expand Down
30 changes: 0 additions & 30 deletions src/diffeq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,36 +113,6 @@ function remove_node_non_user_cache!(integrator::DiffEqBase.AbstractODEIntegrato
nothing
end

function add_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x,
node...)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
nothing
end

function add_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
nothing
end

function remove_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x,
node...)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
nothing
end

function remove_node_jac_config!(cache, config::SparseDiffTools.ForwardColorJacCache, i, x)
@assert cache.jac_config.colorvec isa UnitRange
cache.jac_config = SparseDiffTools.ForwardColorJacCache(cache.uf, cache.uprev,
config.chunksize)
nothing
end

function add_node_jac_config!(cache, config::FiniteDiff.JacobianCache, i, x)
#add_node!(cache.x1, fill!(similar(x, eltype(cache.x1)),0))
add_node!(config.fx, recursivecopy(x))
Expand Down
Loading