Skip to content

Commit

Permalink
add extension for symbolic indexing of Num
Browse files Browse the repository at this point in the history
  • Loading branch information
MasonProtter committed Sep 30, 2024
1 parent 8d79d33 commit a295c2b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "GraphDynamics"
uuid = "bcd5d0fe-e6b7-4ef1-9848-780c183c7f4c"
version = "0.1.2"
version = "0.1.3"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand All @@ -15,11 +15,20 @@ SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
julia = "1.10"
Accessors = "0.1"
ConstructionBase = "1.5"
OhMyThreads = "0.6"
OhMyThreads = "0.6, 0.7"
RecursiveArrayTools = "3"
SciMLBase = "2"
SparseArrays = "1"
SymbolicIndexingInterface = "0.3"
Symbolics = "6"
ModelingToolkit = "9"

[weakdeps]
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"

[extensions]
MTKExt = ["Symbolics", "ModelingToolkit"]

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
28 changes: 28 additions & 0 deletions ext/MTKExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module MTKExt

using ModelingToolkit: ModelingToolkit, Num
using Symbolics: Symbolics, tosymbol
using GraphDynamics: GraphDynamics, GraphSystem
using SymbolicIndexingInterface: SymbolicIndexingInterface

function SymbolicIndexingInterface.is_variable(sys::GraphSystem, var::Num)
SymbolicIndexingInterface.is_variable(sys, tosymbol(var; escape=false))
end

function SymbolicIndexingInterface.variable_index(sys::GraphSystem, var::Num)
SymbolicIndexingInterface.variable_index(sys, tosymbol(var; escape=false))
end

function SymbolicIndexingInterface.is_parameter(sys::GraphSystem, var::Num)
SymbolicIndexingInterface.is_parameter(sys, tosymbol(var; escape=false))
end

function SymbolicIndexingInterface.parameter_index(sys::GraphSystem, var::Num)
SymbolicIndexingInterface.parameter_index(sys, tosymbol(var; escape=false))
end

function SymbolicIndexingInterface.is_independent_variable(sys::GraphSystem, sym::Num)
SymbolicIndexingInterface.is_independent_variable(sys, tosymbol(var; escape=false))
end

end

0 comments on commit a295c2b

Please sign in to comment.