Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ jobs:
- ModelingToolkitBase/Extended
- ModelingToolkitBase/RegressionI
- ModelingToolkitBase/Extensions
- ModelingToolkitBase/QA
- SciCompDSL/All
exclude:
- version: "pre"
pkggroup: ModelingToolkitBase/QA
runs-on: ${{ vars.USE_SELF_HOSTED == 'true' && 'self-hosted' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v6
Expand Down
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
Ipopt_jll = "9cc047cb-c261-5740-88fc-0cf96f7bdcc7"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
JumpProcesses = "ccbc3e58-028d-4f4c-8cd5-9ae44345cda5"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
Expand Down Expand Up @@ -170,4 +169,4 @@ TestEnv = "1e6cf692-eddd-4d53-88a5-2d735e33781b"
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"

[targets]
test = ["AmplNLWriter", "BenchmarkTools", "BoundaryValueDiffEqMIRK", "BoundaryValueDiffEqAscher", "ControlSystemsBase", "DataInterpolations", "DelayDiffEq", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "OrdinaryDiffEqCore", "OrdinaryDiffEqDefault", "REPL", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "Pkg", "JET", "OrdinaryDiffEqNonlinearSolve", "Logging", "OptimizationBase", "LinearSolve", "Latexify", "Distributed", "DiffEqNoiseProcess", "DynamicQuantities", "DiffEqCallbacks", "URIs", "JumpProcesses", "RecursiveArrayTools", "SciMLStructures", "SpecialFunctions", "SciCompDSL"]
test = ["AmplNLWriter", "BenchmarkTools", "BoundaryValueDiffEqMIRK", "BoundaryValueDiffEqAscher", "ControlSystemsBase", "DataInterpolations", "DelayDiffEq", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "OrdinaryDiffEqCore", "OrdinaryDiffEqDefault", "REPL", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "Pkg", "OrdinaryDiffEqNonlinearSolve", "Logging", "OptimizationBase", "LinearSolve", "Latexify", "Distributed", "DiffEqNoiseProcess", "DynamicQuantities", "DiffEqCallbacks", "URIs", "JumpProcesses", "RecursiveArrayTools", "SciMLStructures", "SpecialFunctions", "SciCompDSL"]
3 changes: 1 addition & 2 deletions lib/ModelingToolkitBase/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
Ipopt_jll = "9cc047cb-c261-5740-88fc-0cf96f7bdcc7"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Expand All @@ -210,4 +209,4 @@ Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["AmplNLWriter", "BenchmarkTools", "BoundaryValueDiffEqMIRK", "BoundaryValueDiffEqAscher", "ControlSystemsBase", "DataInterpolations", "DelayDiffEq", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationIpopt", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "OrdinaryDiffEqDefault", "REPL", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "Pkg", "JET", "OrdinaryDiffEqNonlinearSolve", "Logging", "OptimizationBase", "LinearSolve", "Latexify", "Distributed", "DiffEqNoiseProcess", "DynamicQuantities"]
test = ["AmplNLWriter", "BenchmarkTools", "BoundaryValueDiffEqMIRK", "BoundaryValueDiffEqAscher", "ControlSystemsBase", "DataInterpolations", "DelayDiffEq", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationIpopt", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "OrdinaryDiffEqDefault", "REPL", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "Pkg", "OrdinaryDiffEqNonlinearSolve", "Logging", "OptimizationBase", "LinearSolve", "Latexify", "Distributed", "DiffEqNoiseProcess", "DynamicQuantities"]
22 changes: 0 additions & 22 deletions lib/ModelingToolkitBase/test/mtkparameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ using BlockArrays: BlockedArray, BlockedVector, Block
using OrdinaryDiffEq
using DiffEqBase
using ForwardDiff
using JET
using Test

@discretes c(t)
Expand Down Expand Up @@ -187,8 +186,6 @@ ps = [p => 1.0] # Value for `d` is missing
@test_throws "Could not evaluate" ODEProblem(sys, [u0; ps], tspan)
@test_nowarn ODEProblem(sys, [u0; ps; [d => 1.0]], tspan)

# JET tests

# scalar parameters only
function level1()
@parameters p1 = 0.5 [tunable = true] p2 = 1 [tunable = true] p3 = 3 [tunable = false] p4 = 3 [tunable = true] y0
Expand Down Expand Up @@ -257,35 +254,16 @@ end
@testset "Type stability of $portion" for portion in [
Tunable(), Discrete(), Constants(),
]
@test_call canonicalize(portion, ps)
@inferred canonicalize(portion, ps)

# broken because the size of a vector of vectors can't be determined at compile time
@test_opt target_modules = (ModelingToolkitBase,) canonicalize(
portion, ps
)

buffer, repack, alias = canonicalize(portion, ps)

# broken because dependent update functions break inference
@test_call target_modules = (ModelingToolkitBase,) SciMLStructures.replace(
portion, ps, ones(length(buffer))
)
@inferred SciMLStructures.replace(
portion, ps, ones(length(buffer))
)
@inferred MTKParameters SciMLStructures.replace(portion, ps, ones(length(buffer)))
@test_opt target_modules = (ModelingToolkitBase,) SciMLStructures.replace(
portion, ps, ones(length(buffer))
)

@test_call target_modules = (ModelingToolkitBase,) SciMLStructures.replace!(
portion, ps, ones(length(buffer))
)
@inferred SciMLStructures.replace!(portion, ps, ones(length(buffer)))
@test_opt target_modules = (ModelingToolkitBase,) SciMLStructures.replace!(
portion, ps, ones(length(buffer))
)
end
end

Expand Down
10 changes: 10 additions & 0 deletions lib/ModelingToolkitBase/test/qa/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
ModelingToolkitBase = "7771a370-6774-4173-bd38-47e70ca0b839"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SciMLStructures = "53ae85a6-f571-4167-b2af-e1d143709226"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
ModelingToolkitBase = {path = "../.."}
4 changes: 4 additions & 0 deletions lib/ModelingToolkitBase/test/qa/aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using ModelingToolkitBase
using Aqua

Aqua.test_all(ModelingToolkitBase)
100 changes: 100 additions & 0 deletions lib/ModelingToolkitBase/test/qa/jet.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using ModelingToolkitBase
using ModelingToolkitBase: t_nounits as t, MTKParameters
using SciMLBase
using SciMLStructures: SciMLStructures, canonicalize, Tunable, Discrete, Constants
using JET
using Test

# scalar parameters only
function level1()
@parameters p1 = 0.5 [tunable = true] p2 = 1 [tunable = true] p3 = 3 [tunable = false] p4 = 3 [tunable = true] y0
@variables x(t) = 2 y(t) = y0
D = Differential(t)

eqs = [
D(x) ~ p1 * x - p2 * x * y
D(y) ~ -p3 * y + p4 * x * y
]

sys = mtkcompile(
complete(
System(
eqs, t, name = :sys, bindings = [y0 => 2p4]
)
)
)
return prob = ODEProblem{true, SciMLBase.FullSpecialize}(sys, [], (0.0, 3.0))
end

# scalar and vector parameters
function level2()
@parameters p1 = 0.5 [tunable = true] (p23[1:2] = [1, 3.0]) [tunable = true] p4 = 3 [tunable = false] y0
@variables x(t) = 2 y(t) = y0
D = Differential(t)

eqs = [
D(x) ~ p1 * x - p23[1] * x * y
D(y) ~ -p23[2] * y + p4 * x * y
]

sys = mtkcompile(
complete(
System(
eqs, t, name = :sys, bindings = [y0 => 2p4]
)
)
)
return prob = ODEProblem{true, SciMLBase.FullSpecialize}(sys, [], (0.0, 3.0))
end

# scalar and vector parameters with different scalar types
function level3()
@parameters p1 = 0.5 [tunable = true] (p23[1:2] = [1, 3.0]) [tunable = true] p4::Int = 3 [tunable = true] y0::Int
@variables x(t) = 2 y(t) = y0
D = Differential(t)

eqs = [
D(x) ~ p1 * x - p23[1] * x * y
D(y) ~ -p23[2] * y + p4 * x * y
]

sys = mtkcompile(
complete(
System(
eqs, t, name = :sys, bindings = [y0 => 2p4]
)
)
)
return prob = ODEProblem{true, SciMLBase.FullSpecialize}(sys, [], (0.0, 3.0))
end

@testset "level$i" for (i, prob) in enumerate([level1(), level2(), level3()])
ps = prob.p
@testset "Type stability of $portion" for portion in [
Tunable(), Discrete(), Constants(),
]
@test_call canonicalize(portion, ps)

# broken because the size of a vector of vectors can't be determined at compile time
@test_opt target_modules = (ModelingToolkitBase,) canonicalize(
portion, ps
)

buffer, repack, alias = canonicalize(portion, ps)

# broken because dependent update functions break inference
@test_call target_modules = (ModelingToolkitBase,) SciMLStructures.replace(
portion, ps, ones(length(buffer))
)
@test_opt target_modules = (ModelingToolkitBase,) SciMLStructures.replace(
portion, ps, ones(length(buffer))
)

@test_call target_modules = (ModelingToolkitBase,) SciMLStructures.replace!(
portion, ps, ones(length(buffer))
)
@test_opt target_modules = (ModelingToolkitBase,) SciMLStructures.replace!(
portion, ps, ones(length(buffer))
)
end
end
12 changes: 12 additions & 0 deletions lib/ModelingToolkitBase/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ function activate_extensions_env()
return Pkg.instantiate()
end

function activate_qa_env()
Pkg.activate("qa")
Pkg.develop([PackageSpec(path = dirname(@__DIR__))])
return Pkg.instantiate()
end

function activate_downstream_env()
Pkg.activate("downstream")
Pkg.develop([PackageSpec(path = dirname(@__DIR__))])
Expand Down Expand Up @@ -114,4 +120,10 @@ end
# @safetestset "Auto Differentiation Test" include("extensions/ad.jl")
@safetestset "Dynamic Optimization Collocation Solvers" include("extensions/dynamic_optimization.jl")
end

if GROUP == "All" || GROUP == "QA"
activate_qa_env()
@safetestset "JET Tests" include("qa/jet.jl")
@safetestset "Aqua Tests" include("qa/aqua.jl")
end
end
10 changes: 8 additions & 2 deletions lib/ModelingToolkitBase/test/sdesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,14 @@ end

prob = SDEProblem(de, [u0map; parammap], (0.0, 1.0))

function prob_func(prob, ctx)
remake(prob, seed = seeds[ctx.i])
@static if pkgversion(SciMLBase) < v"3"
function prob_func(prob, i, repeat)
remake(prob, seed = seeds[i])
end
else
function prob_func(prob, ctx)
remake(prob, seed = seeds[ctx.i])
end
end
numtraj = Int(1.0e3)
seed = 100
Expand Down
Loading