Skip to content

Commit

Permalink
Use OrderedDict for variable_symbols (#12)
Browse files Browse the repository at this point in the history
* use `OrderedDict` for `variable_symbols`

* bump version
  • Loading branch information
MasonProtter authored Nov 14, 2024
1 parent b6ec333 commit ad2b71f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
22 changes: 12 additions & 10 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
name = "GraphDynamics"
uuid = "bcd5d0fe-e6b7-4ef1-9848-780c183c7f4c"
version = "0.2.0"
version = "0.2.1"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
OhMyThreads = "67456a42-1dca-4109-a031-0a68de7e3ad5"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"

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

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

[compat]
julia = "1.10"
Accessors = "0.1"
ConstructionBase = "1.5"
ModelingToolkit = "9"
OhMyThreads = "0.6, 0.7"
OrderedCollections = "1.6.3"
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"]
julia = "1.10"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
5 changes: 5 additions & 0 deletions src/GraphDynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ using SparseArrays:
rowvals,
nzrange

using OrderedCollections:
OrderedCollections,
OrderedDict


#----------------------------------------------------------
# Random utils
include("utils.jl")
Expand Down
4 changes: 2 additions & 2 deletions src/symbolic_indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct ParamIndex #todo: this'll require some generalization to support weight p
end

function compute_namemap(names_partitioned, states_partitioned::Tuple{Vararg{AbstractVector{<:SubsystemStates}}})
state_namemap = Dict{Symbol, StateIndex}()
state_namemap = OrderedDict{Symbol, StateIndex}()
for i eachindex(names_partitioned, states_partitioned)
for j eachindex(names_partitioned[i], states_partitioned[i])
for (k, name) enumerate(propertynames(states_partitioned[i][j]))
Expand All @@ -28,7 +28,7 @@ function compute_namemap(names_partitioned, states_partitioned::Tuple{Vararg{Abs
state_namemap
end
function compute_namemap(names_partitioned, params_partitioned::Tuple{Vararg{AbstractVector{<:SubsystemParams}}})
param_namemap = Dict{Symbol, ParamIndex}()
param_namemap = OrderedDict{Symbol, ParamIndex}()
for i eachindex(names_partitioned, params_partitioned)
for j eachindex(names_partitioned[i], params_partitioned[i])
for name propertynames(params_partitioned[i][j])
Expand Down

2 comments on commit ad2b71f

@MasonProtter
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/119446

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.1 -m "<description of version>" ad2b71fe7b7578600f69da67638b101e43ceba4e
git push origin v0.2.1

Please sign in to comment.