Skip to content

Commit 882f721

Browse files
authored
Merge pull request #2425 from oxinabox/ox/nomacrotools
Replace MacroTools with ExprTools & Base.remove_lines!
2 parents 0e04e8a + 67f1b77 commit 882f721

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
1818
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1919
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
2020
DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"
21+
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
2122
FindFirstFunctions = "64ca27bc-2ba2-4a57-88aa-44e436879224"
2223
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
2324
FunctionWrappersWrappers = "77dc65aa-8811-40c2-897b-53d922fa7daf"
@@ -31,7 +32,6 @@ Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
3132
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
3233
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
3334
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
34-
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
3535
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
3636
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
3737
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
@@ -75,6 +75,7 @@ Distributions = "0.23, 0.24, 0.25"
7575
DocStringExtensions = "0.7, 0.8, 0.9"
7676
DomainSets = "0.6"
7777
DynamicQuantities = "^0.11.2"
78+
ExprTools = "0.1.10"
7879
FindFirstFunctions = "1"
7980
ForwardDiff = "0.10.3"
8081
FunctionWrappersWrappers = "0.1"
@@ -88,7 +89,6 @@ Latexify = "0.11, 0.12, 0.13, 0.14, 0.15, 0.16"
8889
Libdl = "1"
8990
LinearAlgebra = "1"
9091
MLStyle = "0.4.17"
91-
MacroTools = "0.5"
9292
NaNMath = "0.3, 1"
9393
OrdinaryDiffEq = "6"
9494
PrecompileTools = "1"

src/ModelingToolkit.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ using PrecompileTools, Reexport
1313
using StaticArrays, LinearAlgebra, SparseArrays, LabelledArrays
1414
using InteractiveUtils
1515
using Latexify, Unitful, ArrayInterface
16-
using MacroTools
1716
using Setfield, ConstructionBase
1817
using JumpProcesses
1918
using DataStructures
@@ -23,7 +22,7 @@ using PrecompileTools, Reexport
2322
using Base.Threads
2423
using DiffEqCallbacks
2524
using Graphs
26-
import MacroTools: splitdef, combinedef, postwalk, striplines
25+
import ExprTools: splitdef, combinedef
2726
import Libdl
2827
using DocStringExtensions
2928
using Base: RefValue

src/systems/abstractsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ function toexpr(sys::AbstractSystem)
921921
name = $name, checks = false)))
922922
end
923923

924-
striplines(expr) # keeping the line numbers is never helpful
924+
Base.remove_linenums!(expr) # keeping the line numbers is never helpful
925925
end
926926

927927
Base.write(io::IO, sys::AbstractSystem) = write(io, readable_code(toexpr(sys)))

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
757757
sparsity = $(sparsity ? jacobian_sparsity(sys) : nothing),
758758
observed = $observedfun_exp)
759759
end
760-
!linenumbers ? striplines(ex) : ex
760+
!linenumbers ? Base.remove_linenums!(ex) : ex
761761
end
762762

763763
"""
@@ -886,7 +886,7 @@ function DAEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
886886
$_f
887887
ODEFunction{$iip}($fsym)
888888
end
889-
!linenumbers ? striplines(ex) : ex
889+
!linenumbers ? Base.remove_linenums!(ex) : ex
890890
end
891891

892892
function DAEFunctionExpr(sys::AbstractODESystem, args...; kwargs...)
@@ -1201,7 +1201,7 @@ function ODEProblemExpr{iip}(sys::AbstractODESystem, u0map, tspan,
12011201
p = $p
12021202
$odep
12031203
end
1204-
!linenumbers ? striplines(ex) : ex
1204+
!linenumbers ? Base.remove_linenums!(ex) : ex
12051205
end
12061206

12071207
function ODEProblemExpr(sys::AbstractODESystem, args...; kwargs...)
@@ -1250,7 +1250,7 @@ function DAEProblemExpr{iip}(sys::AbstractODESystem, du0map, u0map, tspan,
12501250
differential_vars = $differential_vars
12511251
$prob
12521252
end
1253-
!linenumbers ? striplines(ex) : ex
1253+
!linenumbers ? Base.remove_linenums!(ex) : ex
12541254
end
12551255

12561256
function DAEProblemExpr(sys::AbstractODESystem, args...; kwargs...)
@@ -1320,7 +1320,7 @@ function SteadyStateProblemExpr{iip}(sys::AbstractODESystem, u0map,
13201320
p = $p
13211321
$prob
13221322
end
1323-
!linenumbers ? striplines(ex) : ex
1323+
!linenumbers ? Base.remove_linenums!(ex) : ex
13241324
end
13251325

13261326
function SteadyStateProblemExpr(sys::AbstractODESystem, args...; kwargs...)

src/systems/diffeqs/sdesystem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ function SDEFunctionExpr{iip}(sys::SDESystem, dvs = states(sys),
562562
indepsym = $(Symbol(get_iv(sys))),
563563
paramsyms = $(Symbol.(parameters(sys))))
564564
end
565-
!linenumbers ? striplines(ex) : ex
565+
!linenumbers ? Base.remove_linenums!(ex) : ex
566566
end
567567

568568
function SDEFunctionExpr(sys::SDESystem, args...; kwargs...)
@@ -656,7 +656,7 @@ function SDEProblemExpr{iip}(sys::SDESystem, u0map, tspan,
656656
SDEProblem(f, u0, tspan, p; noise_rate_prototype = noise_rate_prototype,
657657
$(kwargs...))
658658
end
659-
!linenumbers ? striplines(ex) : ex
659+
!linenumbers ? Base.remove_linenums!(ex) : ex
660660
end
661661

662662
function SDEProblemExpr(sys::SDESystem, args...; kwargs...)

src/systems/discrete_system/discrete_system.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ function DiscreteFunctionExpr{iip}(sys::DiscreteSystem, dvs = states(sys),
412412
indepsym = $(QuoteNode(Symbol(get_iv(sys)))),
413413
paramsyms = $(Symbol.(parameters(sys))))
414414
end
415-
!linenumbers ? striplines(ex) : ex
415+
!linenumbers ? Base.remove_linenums!(ex) : ex
416416
end
417417

418418
function DiscreteFunctionExpr(sys::DiscreteSystem, args...; kwargs...)
@@ -460,5 +460,5 @@ function DiscreteProblemExpr{iip}(sys::DiscreteSystem, u0map, tspan,
460460
tspan = $tspan
461461
DiscreteProblem(f, u0, tspan, p; $(filter_kwargs(kwargs)...))
462462
end
463-
!linenumbers ? striplines(ex) : ex
463+
!linenumbers ? Base.remove_linenums!(ex) : ex
464464
end

src/systems/nonlinear/nonlinearsystem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function NonlinearFunctionExpr{iip}(sys::NonlinearSystem, dvs = states(sys),
318318
syms = $(Symbol.(states(sys))),
319319
paramsyms = $(Symbol.(parameters(sys))))
320320
end
321-
!linenumbers ? striplines(ex) : ex
321+
!linenumbers ? Base.remove_linenums!(ex) : ex
322322
end
323323

324324
function process_NonlinearProblem(constructor, sys::NonlinearSystem, u0map, parammap;
@@ -406,7 +406,7 @@ function NonlinearProblemExpr{iip}(sys::NonlinearSystem, u0map,
406406
p = $p
407407
NonlinearProblem(f, u0, p; $(filter_kwargs(kwargs)...))
408408
end
409-
!linenumbers ? striplines(ex) : ex
409+
!linenumbers ? Base.remove_linenums!(ex) : ex
410410
end
411411

412412
function flatten(sys::NonlinearSystem, noeqs = false)

0 commit comments

Comments
 (0)