Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Dec 1, 2024
1 parent a281b83 commit 79cf520
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/initializationsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sol = solve(initprob)

initprob = ModelingToolkit.InitializationProblem(pend, 0.0, [x => 1, y => 0], [g => 1];
guesses = ModelingToolkit.missing_variable_defaults(pend))
@test initprob isa NonlinearProblem
@test initprob isa NonlinearLeastSquaresProblem
sol = solve(initprob)
@test SciMLBase.successful_retcode(sol)
@test sol.u == [0.0, 0.0, 0.0, 0.0]
Expand Down
4 changes: 2 additions & 2 deletions test/mtkparameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ end

# Parameter timeseries
ps = MTKParameters(([1.0, 1.0],), (BlockedArray(zeros(4), [2, 2]),),
(), ())
(), (), ())
ps2 = SciMLStructures.replace(Discrete(), ps, ones(4))
@test typeof(ps2.discrete) == typeof(ps.discrete)
with_updated_parameter_timeseries_values(
Expand All @@ -316,7 +316,7 @@ with_updated_parameter_timeseries_values(
ps = MTKParameters(
(), (BlockedArray([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], [3, 3]),
BlockedArray(falses(1), [1, 0])),
(), ())
(), (), ())
@test SciMLBase.get_saveable_values(sys, ps, 1).x isa Tuple{Vector{Float64}, Vector{Bool}}
tsidx1 = 1
tsidx2 = 2
Expand Down
3 changes: 2 additions & 1 deletion test/scc_nonlinear_problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using NonlinearSolve, SCCNonlinearSolve
using OrdinaryDiffEq
using SciMLBase, Symbolics
using LinearAlgebra, Test
using ModelingToolkit: t_nounits as t, D_nounits as D

@testset "Trivial case" begin
function f!(du, u, p)
Expand Down Expand Up @@ -30,7 +31,7 @@ using LinearAlgebra, Test
sol2 = solve(sccprob, NewtonRaphson())
@test SciMLBase.successful_retcode(sol1)
@test SciMLBase.successful_retcode(sol2)
@test sol1.u sol2.u
@test sol1[u] sol2[u]
end

@testset "With parameters" begin
Expand Down
2 changes: 1 addition & 1 deletion test/split_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ S = get_sensitivity(closed_loop, :u)
BlockedArray([[1 2; 3 4], [2 4; 6 8]], [1, 1])),
# (BlockedArray([[true, false], [false, true]]), BlockedArray([[[1 2; 3 4]], [[2 4; 6 8]]])),
([5, 6],),
(["hi", "bye"], [:lie, :die]))
(["hi", "bye"], [:lie, :die]), ())
@test ps[ParameterIndex(Tunable(), 1)] == 1.0
@test ps[ParameterIndex(Tunable(), 2:4)] == collect(2.0:4.0)
@test ps[ParameterIndex(Tunable(), reshape(4:7, 2, 2))] == reshape(4.0:7.0, 2, 2)
Expand Down

0 comments on commit 79cf520

Please sign in to comment.