Skip to content

Commit

Permalink
Move SparseArrays to Ext
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Jul 27, 2024
1 parent 9a4a7cf commit 67cc4b8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Expand All @@ -45,6 +44,7 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

Expand All @@ -58,6 +58,7 @@ DiffEqBaseMPIExt = "MPI"
DiffEqBaseMeasurementsExt = "Measurements"
DiffEqBaseMonteCarloMeasurementsExt = "MonteCarloMeasurements"
DiffEqBaseReverseDiffExt = "ReverseDiff"
DiffEqBaseSparseArraysExt = "SparseArrays"
DiffEqBaseTrackerExt = "Tracker"
DiffEqBaseUnitfulExt = "Unitful"

Expand Down
13 changes: 13 additions & 0 deletions ext/DiffEqBaseSparseArraysExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module DiffEqBaseSparseArraysExt

import SparseArrays
import DiffEqBase: NAN_CHECK, INFINITE_OR_GIANT

function NAN_CHECK(x::SparseArrays.AbstractSparseMatrixCSC)
any(NAN_CHECK, SparseArrays.nonzeros(x))
end
function INFINITE_OR_GIANT(x::SparseArrays.AbstractSparseMatrixCSC)
any(INFINITE_OR_GIANT, SparseArrays.nonzeros(x))
end

end
1 change: 0 additions & 1 deletion src/DiffEqBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ using FastBroadcast: @.., True, False
using Static: reduce_tup

import RecursiveArrayTools
import SparseArrays
import TruncatedStacktraces

using Setfield
Expand Down
6 changes: 0 additions & 6 deletions src/common_defaults.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ function NAN_CHECK(x::Union{AbstractArray, RecursiveArrayTools.AbstractVectorOfA
NAN_CHECK, x)
end
NAN_CHECK(x::RecursiveArrayTools.ArrayPartition) = any(NAN_CHECK, x.x)
function NAN_CHECK(x::SparseArrays.AbstractSparseMatrixCSC)
any(NAN_CHECK, SparseArrays.nonzeros(x))
end

INFINITE_OR_GIANT(x::Number) = !isfinite(x)
function INFINITE_OR_GIANT(x::Union{
Expand All @@ -113,9 +110,6 @@ function INFINITE_OR_GIANT(x::Union{
INFINITE_OR_GIANT, x)
end
INFINITE_OR_GIANT(x::RecursiveArrayTools.ArrayPartition) = any(INFINITE_OR_GIANT, x.x)
function INFINITE_OR_GIANT(x::SparseArrays.AbstractSparseMatrixCSC)
any(INFINITE_OR_GIANT, SparseArrays.nonzeros(x))
end
ODE_DEFAULT_UNSTABLE_CHECK(dt, u, p, t) = false
function ODE_DEFAULT_UNSTABLE_CHECK(dt, u::Union{Number, AbstractArray{<:Number}}, p, t)
INFINITE_OR_GIANT(u)
Expand Down
2 changes: 1 addition & 1 deletion test/ode_default_unstable_check.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Test, RecursiveArrayTools, StaticArrays, SparseArrays
using Test, RecursiveArrayTools, StaticArrays

using DiffEqBase: NAN_CHECK

Expand Down

0 comments on commit 67cc4b8

Please sign in to comment.