Skip to content

Commit feda4b3

Browse files
Merge pull request #3959 from ChrisRackauckas-Claude/datastructures-v0.18-v0.19-compat
Add DataStructures v0.17-v0.19 compatibility with version branching
2 parents acb124a + 3eab473 commit feda4b3

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ CommonSolve = "0.2.4"
9898
Compat = "3.42, 4"
9999
ConstructionBase = "1"
100100
DataInterpolations = "7, 8"
101-
DataStructures = "0.17, 0.18"
101+
DataStructures = "0.17, 0.18, 0.19"
102102
DeepDiffs = "1"
103103
DelayDiffEq = "5.61"
104104
DiffEqBase = "6.189.1"

src/ModelingToolkit.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ using LinearAlgebra, SparseArrays
2929
using InteractiveUtils
3030
using JumpProcesses
3131
using DataStructures
32+
@static if pkgversion(DataStructures) >= v"0.19"
33+
import DataStructures: IntDisjointSet
34+
else
35+
import DataStructures: IntDisjointSets
36+
const IntDisjointSet = IntDisjointSets
37+
end
3238
using Base.Threads
3339
using Latexify, Unitful, ArrayInterface
3440
using Setfield, ConstructionBase

src/systems/alias_elimination.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,20 +426,32 @@ function topsort_equations(eqs, unknowns; check = true)
426426

427427
q = Queue{Int}(neqs)
428428
for (i, d) in enumerate(degrees)
429-
d == 0 && enqueue!(q, i)
429+
@static if pkgversion(DataStructures) >= v"0.19"
430+
d == 0 && push!(q, i)
431+
else
432+
d == 0 && enqueue!(q, i)
433+
end
430434
end
431435

432436
idx = 0
433437
ordered_eqs = similar(eqs, 0)
434438
sizehint!(ordered_eqs, neqs)
435439
while !isempty(q)
436-
𝑠eq = dequeue!(q)
440+
@static if pkgversion(DataStructures) >= v"0.19"
441+
𝑠eq = popfirst!(q)
442+
else
443+
𝑠eq = dequeue!(q)
444+
end
437445
idx += 1
438446
push!(ordered_eqs, eqs[𝑠eq])
439447
var = assigns[𝑠eq]
440448
for 𝑑eq in 𝑑neighbors(graph, var)
441449
degree = degrees[𝑑eq] = degrees[𝑑eq] - 1
442-
degree == 0 && enqueue!(q, 𝑑eq)
450+
@static if pkgversion(DataStructures) >= v"0.19"
451+
degree == 0 && push!(q, 𝑑eq)
452+
else
453+
degree == 0 && enqueue!(q, 𝑑eq)
454+
end
443455
end
444456
end
445457

src/systems/connectiongraph.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ function connectionsets(graph::HyperGraph{V}) where {V}
455455
invmap = graph.invmap
456456

457457
# union all of the hyperedges
458-
disjoint_sets = IntDisjointSets(length(invmap))
458+
disjoint_sets = IntDisjointSet(length(invmap))
459459
for edge_i in 𝑠vertices(bigraph)
460460
hyperedge = 𝑠neighbors(bigraph, edge_i)
461461
isempty(hyperedge) && continue

0 commit comments

Comments
 (0)