From 3eab4733d2ec52ebdc37f4bc0739846033e04ba2 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas Date: Wed, 8 Oct 2025 05:58:39 -0400 Subject: [PATCH] Add DataStructures v0.17-v0.19 compatibility with version branching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update Project.toml compat to support v0.17, v0.18, and v0.19 - Add conditional imports for IntDisjointSet (v0.19) vs IntDisjointSets (v0.17-v0.18) - Add conditional Queue operations: push!/popfirst! (v0.19) vs enqueue!/dequeue! (v0.17-v0.18) - Use @static if with pkgversion() to select appropriate functions at compile time - Update IntDisjointSets usage in connectiongraph.jl to use IntDisjointSet alias This maintains backward compatibility with v0.17 and v0.18 while adding v0.19 support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- Project.toml | 2 +- src/ModelingToolkit.jl | 6 ++++++ src/systems/alias_elimination.jl | 18 +++++++++++++++--- src/systems/connectiongraph.jl | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index d5addf3399..1206e921b3 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.17, 0.18" +DataStructures = "0.17, 0.18, 0.19" DeepDiffs = "1" DelayDiffEq = "5.61" DiffEqBase = "6.189.1" diff --git a/src/ModelingToolkit.jl b/src/ModelingToolkit.jl index 4f29c5f428..6c79eb4fb1 100644 --- a/src/ModelingToolkit.jl +++ b/src/ModelingToolkit.jl @@ -29,6 +29,12 @@ using LinearAlgebra, SparseArrays using InteractiveUtils using JumpProcesses using DataStructures +@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 f24a2562fe..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 && enqueue!(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 = dequeue!(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 && enqueue!(q, 𝑑eq) + @static if pkgversion(DataStructures) >= v"0.19" + degree == 0 && push!(q, 𝑑eq) + else + degree == 0 && enqueue!(q, 𝑑eq) + end end end diff --git a/src/systems/connectiongraph.jl b/src/systems/connectiongraph.jl index 99110e37e9..27e542c2ab 100644 --- a/src/systems/connectiongraph.jl +++ b/src/systems/connectiongraph.jl @@ -455,7 +455,7 @@ function connectionsets(graph::HyperGraph{V}) where {V} invmap = graph.invmap # union all of the hyperedges - disjoint_sets = IntDisjointSets(length(invmap)) + disjoint_sets = IntDisjointSet(length(invmap)) for edge_i in 𝑠vertices(bigraph) hyperedge = 𝑠neighbors(bigraph, edge_i) isempty(hyperedge) && continue