From 01547d6cb969364d32c6e6e7be340912f4ddaaac Mon Sep 17 00:00:00 2001 From: Albin Heimerson Date: Thu, 27 Jan 2022 19:18:20 +0100 Subject: [PATCH] Fix some test warnings --- test/test_connections.jl | 5 ++--- test/test_freqresp.jl | 4 ++-- test/test_timeresp.jl | 10 +++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/test/test_connections.jl b/test/test_connections.jl index f330e52f7..987fc23ad 100644 --- a/test/test_connections.jl +++ b/test/test_connections.jl @@ -173,10 +173,9 @@ arr4[1] = ss(0); arr4[2] = ss(1); arr4[3] = ss(2) @test [C_111 1.0] == ss([1.0], [2.0 0.0], [3.0], [4.0 1.0]) @test [1.0 C_111] == ss([1.0], [0.0 2.0], [3.0], [1.0 4.0]) @test [C_111 1.0] isa StateSpace{Continuous,Float64} -@test [C_111 1.0].Ts == 0.0 -@test_logs (:warn, +@test (@test_logs (:warn, "Getting time 0.0 for non-discrete systems is deprecated. Check `isdiscrete` before trying to access time." - ) [C_111 1.0].Ts + ) [C_111 1.0].Ts) == 0.0 # Concatenation of discrete system with matrix @test [D_222 fill(1.5, 2, 2)] == [D_222 ss(fill(1.5, 2, 2),0.005)] @test [C_222 fill(1.5, 2, 2)] == [C_222 ss(fill(1.5, 2, 2))] diff --git a/test/test_freqresp.jl b/test/test_freqresp.jl index 1a652ed8b..60ffe9d76 100644 --- a/test/test_freqresp.jl +++ b/test/test_freqresp.jl @@ -11,8 +11,8 @@ G = ss([-5 0 0 0; 0 -1 -2.5 0; 0 4 0 0; 0 0 0 -6], [2 0; 0 1; 0 0; 0 2], @test evalfr(H, -1) == [0.0 -0.3; 0.0 0.4] @test evalfr(H, 0) ≈ [0.0 0.0; 0.2 1/3] -@test evalfr(G, -6) == [Inf Inf; Inf Inf] -@test evalfr(G, -5) == [Inf Inf; Inf Inf] +@test (@test_logs (:warn, "Got exception SingularException(4), returning Inf") evalfr(G, -6)) == [Inf Inf; Inf Inf] +@test (@test_logs (:warn, "Got exception SingularException(1), returning Inf") evalfr(G, -5)) == [Inf Inf; Inf Inf] @test evalfr(G, -1) ≈ [0.0 -0.3; 0.0 0.4] @test evalfr(G, 0) ≈ [0.0 0.0; 0.2 1/3] diff --git a/test/test_timeresp.jl b/test/test_timeresp.jl index c59020537..d18e04956 100644 --- a/test/test_timeresp.jl +++ b/test/test_timeresp.jl @@ -10,15 +10,15 @@ Q = I # eye(2) R = I # eye(1) L = lqr(sys,Q,R) -u(x,i) = -L*x # Form control law +u1(x,i) = -L*x # Form control law t=0:0.1:50 x0 = [1.,0] -y, t, x, uout = lsim(sys,u,t,x0=x0) # Continuous time +y, t, x, uout = lsim(sys,u1,t,x0=x0) # Continuous time th = 1e-6 @test sum(abs.(x[:,end])) < th -y, t, x, uout = lsim(c2d(sys,0.1),u,t,x0=x0) # Discrete time +y, t, x, uout = lsim(c2d(sys,0.1),u1,t,x0=x0) # Discrete time @test sum(abs.(x[:,end])) < th #Do a manual simulation with uout @@ -83,8 +83,8 @@ G2 = ss(1.0im, 1, 1, 0, 1) # Test that the discrete lsim accepts u function that returns scalar L = lqr(sysd,Q,R) -u(x,i) = -L*x -yd, td, xd = lsim(sysd, u, t, x0=x0) +u2(x,i) = -L*x +yd, td, xd = lsim(sysd, u2, t, x0=x0) @test norm(y - yd)/norm(y) < 0.05 # Since the cost matrices are not discretized, these will differ a bit @test norm(x - xd)/norm(x) < 0.05