-
-
Notifications
You must be signed in to change notification settings - Fork 233
Update DataStructures.jl compatibility to v0.19 #3864
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
Conversation
This one probably needs to wait. |
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Replace enqueue! with push! - Replace dequeue! with popfirst! - Replace IntDisjointSets with IntDisjointSet - Import IntDisjointSet to fix compilation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
2acb404
to
ea30297
Compare
Benchmark Results (Julia vlts)Time benchmarks
Memory benchmarks
|
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
Updated PR to support both DataStructures v0.18 and v0.19I've modified the PR to maintain backward compatibility with DataStructures v0.18 while adding support for v0.19. The changes use compile-time version checking with Changes Made:
Testing:✅ Package successfully instantiated and precompiled with DataStructures v0.19.1 Note:The commit is ready in Patch file available at: |
Instructions to Apply the ChangesThe changes have been committed locally but cannot be pushed due to permission restrictions. Here's how to apply them: Option 1: Apply the patch file# Download the patch
curl -O https://gist.githubusercontent.com/ChrisRackauckas-Claude/[GIST_ID]/raw/0001-Add-version-branching-for-DataStructures-v0.18-and-v.patch
# Or manually create it from the diff below and save as changes.patch
# Apply the patch
git checkout update-datastructures-v0.19
git am < changes.patch
git push origin update-datastructures-v0.19 Option 2: Manual file edits1. Project.toml (line 101)-DataStructures = "0.19"
+DataStructures = "0.18, 0.19" 2. src/ModelingToolkit.jl (lines 31-37) using DataStructures
-import DataStructures: IntDisjointSet
+@static if pkgversion(DataStructures) >= v"0.19"
+ import DataStructures: IntDisjointSet
+else
+ import DataStructures: IntDisjointSets
+ const IntDisjointSet = IntDisjointSets
+end 3. src/systems/alias_elimination.jl (3 locations)Location 1 (line ~429): q = Queue{Int}(neqs)
for (i, d) in enumerate(degrees)
- d == 0 && push!(q, i)
+ @static if pkgversion(DataStructures) >= v"0.19"
+ d == 0 && push!(q, i)
+ else
+ d == 0 && enqueue!(q, i)
+ end
end Location 2 (line ~441): while !isempty(q)
- 𝑠eq = popfirst!(q)
+ @static if pkgversion(DataStructures) >= v"0.19"
+ 𝑠eq = popfirst!(q)
+ else
+ 𝑠eq = dequeue!(q)
+ end Location 3 (line ~451): for 𝑑eq in 𝑑neighbors(graph, var)
degree = degrees[𝑑eq] = degrees[𝑑eq] - 1
- degree == 0 && push!(q, 𝑑eq)
+ @static if pkgversion(DataStructures) >= v"0.19"
+ degree == 0 && push!(q, 𝑑eq)
+ else
+ degree == 0 && enqueue!(q, 𝑑eq)
+ end
end Complete Patch FileClick to expand full patchdiff --git a/Project.toml b/Project.toml
index 3a005fedec..abea2786b5 100644
--- a/Project.toml
+++ b/Project.toml
@@ -98,7 +98,7 @@ CommonSolve = "0.2.4"
Compat = "3.42, 4"
ConstructionBase = "1"
DataInterpolations = "7, 8"
-DataStructures = "0.19"
+DataStructures = "0.18, 0.19"
DeepDiffs = "1"
DelayDiffEq = "5.61"
DiffEqBase = "6.189.1"
diff --git a/src/ModelingToolkit.jl b/src/ModelingToolkit.jl
index dd8562340c..6c79eb4fb1 100644
--- a/src/ModelingToolkit.jl
+++ b/src/ModelingToolkit.jl
@@ -29,7 +29,12 @@ using LinearAlgebra, SparseArrays
using InteractiveUtils
using JumpProcesses
using DataStructures
-import DataStructures: IntDisjointSet
+@static if pkgversion(DataStructures) >= v"0.19"
+ import DataStructures: IntDisjointSet
+else
+ import DataStructures: IntDisjointSets
+ const IntDisjointSet = IntDisjointSets
+end
using Base.Threads
using Latexify, Unitful, ArrayInterface
using Setfield, ConstructionBase
diff --git a/src/systems/alias_elimination.jl b/src/systems/alias_elimination.jl
index f23a863782..dc25378b4a 100644
--- a/src/systems/alias_elimination.jl
+++ b/src/systems/alias_elimination.jl
@@ -426,20 +426,32 @@ function topsort_equations(eqs, unknowns; check = true)
q = Queue{Int}(neqs)
for (i, d) in enumerate(degrees)
- d == 0 && push!(q, i)
+ @static if pkgversion(DataStructures) >= v"0.19"
+ d == 0 && push!(q, i)
+ else
+ d == 0 && enqueue!(q, i)
+ end
end
idx = 0
ordered_eqs = similar(eqs, 0)
sizehint!(ordered_eqs, neqs)
while !isempty(q)
- 𝑠eq = popfirst!(q)
+ @static if pkgversion(DataStructures) >= v"0.19"
+ 𝑠eq = popfirst!(q)
+ else
+ 𝑠eq = dequeue!(q)
+ end
idx += 1
push!(ordered_eqs, eqs[𝑠eq])
var = assigns[𝑠eq]
for 𝑑eq in 𝑑neighbors(graph, var)
degree = degrees[𝑑eq] = degrees[𝑑eq] - 1
- degree == 0 && push!(q, 𝑑eq)
+ @static if pkgversion(DataStructures) >= v"0.19"
+ degree == 0 && push!(q, 𝑑eq)
+ else
+ degree == 0 && enqueue!(q, 𝑑eq)
+ end
end
end |
Summary
enqueue!
withpush!
dequeue!
withpopfirst!
IntDisjointSets
withIntDisjointSet
IntDisjointSet
Test plan
🤖 Generated with Claude Code