Skip to content

test: re-introducing @allocations test #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 5 additions & 5 deletions test/1_test_sim_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ end
u, d = [10, 50], Float64[]
@test updatestate!(linmodel1, u) ≈ zeros(2)
@test updatestate!(linmodel1, u, d) ≈ zeros(2)
@test_skip @allocations(updatestate!(linmodel1, u)) == 0
@test @allocations(updatestate!(linmodel1, u)) == 0
@test linmodel1.x0 ≈ zeros(2)
@test evaloutput(linmodel1) ≈ linmodel1() ≈ [50,30]
@test evaloutput(linmodel1, Float64[]) ≈ linmodel1(Float64[]) ≈ [50,30]
@test_skip @allocations(evaloutput(linmodel1)) == 0
@test @allocations(evaloutput(linmodel1)) == 0
x = initstate!(linmodel1, [10, 60])
@test evaloutput(linmodel1) ≈ [50 + 19.0, 30 + 7.4]
@test preparestate!(linmodel1) ≈ x # new method
Expand Down Expand Up @@ -283,11 +283,11 @@ end
u, d = zeros(2), Float64[]
@test updatestate!(nonlinmodel, u) ≈ zeros(2)
@test updatestate!(nonlinmodel, u, d) ≈ zeros(2)
@test_skip @allocations(updatestate!(nonlinmodel, u)) == 0
@test @allocations(updatestate!(nonlinmodel, u)) == 0
@test nonlinmodel.x0 ≈ zeros(2)
@test evaloutput(nonlinmodel) ≈ nonlinmodel() ≈ zeros(2)
@test evaloutput(nonlinmodel, d) ≈ nonlinmodel(Float64[]) ≈ zeros(2)
@test_skip @allocations(evaloutput(nonlinmodel)) == 0
@test @allocations(evaloutput(nonlinmodel)) == 0

x = initstate!(nonlinmodel, [0, 10]) # do nothing for NonLinModel
@test evaloutput(nonlinmodel) ≈ [0, 0]
Expand Down Expand Up @@ -387,7 +387,7 @@ end
# return nothing (see this issue : https://github.com/JuliaLang/julia/issues/51112):
linearize2!(linmodel, model) = (linearize!(linmodel, model); nothing)
linearize2!(linmodel4, nonlinmodel4)
@test_skip @allocations(linearize2!(linmodel4, nonlinmodel4)) == 0
@test @allocations(linearize2!(linmodel4, nonlinmodel4)) == 0
end

@testitem "NonLinModel real time simulations" setup=[SetupMPCtests] begin
Expand Down
36 changes: 18 additions & 18 deletions test/2_test_state_estim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ end
preparestate!(manual1, y)
@test updatestate!(manual1, u, y, d) ≈ zeros(4)
@test manual1.x̂0 ≈ zeros(4)
@test_skip @allocations(preparestate!(manual1, y)) == 0
@test_skip @allocations(updatestate!(manual1, u, y)) == 0
@test @allocations(preparestate!(manual1, y)) == 0
@test @allocations(updatestate!(manual1, u, y)) == 0
preparestate!(manual1, y)
@test evaloutput(manual1) ≈ manual1() ≈ [50, 30]
@test evaloutput(manual1, d) ≈ manual1(d) ≈ [50, 30]
@test_skip @allocations(evaloutput(manual1, d)) == 0
@test @allocations(evaloutput(manual1, d)) == 0
@test initstate!(manual1, [10, 50], [50, 30+1]) ≈ [zeros(3); [1]]
linmodel2 = LinModel(append(tf(1, [1, 0]), tf(2, [10, 1])), 1.0)
manual2 = SteadyKalmanFilter(linmodel2, nint_u=[1, 1], direct=false)
Expand Down Expand Up @@ -205,12 +205,12 @@ end
preparestate!(kalmanfilter1, y)
@test updatestate!(kalmanfilter1, u, y, d) ≈ zeros(4)
@test kalmanfilter1.x̂0 ≈ zeros(4)
@test_skip @allocations(preparestate!(kalmanfilter1, y)) == 0
@test_skip @allocations(updatestate!(kalmanfilter1, u, y)) == 0
@test @allocations(preparestate!(kalmanfilter1, y)) == 0
@test @allocations(updatestate!(kalmanfilter1, u, y)) == 0
preparestate!(kalmanfilter1, y)
@test evaloutput(kalmanfilter1) ≈ kalmanfilter1() ≈ [50, 30]
@test evaloutput(kalmanfilter1, d) ≈ kalmanfilter1(d) ≈ [50, 30]
@test_skip @allocations(evaloutput(kalmanfilter1, d)) == 0
@test @allocations(evaloutput(kalmanfilter1, d)) == 0
@test initstate!(kalmanfilter1, [10, 50], [50, 30+1]) ≈ [zeros(3); [1]]
setstate!(kalmanfilter1, [1,2,3,4], diagm(.1:.1:.4))
@test kalmanfilter1.x̂0 ≈ [1,2,3,4]
Expand Down Expand Up @@ -326,12 +326,12 @@ end
preparestate!(lo1, y)
@test updatestate!(lo1, u, y, d) ≈ zeros(4)
@test lo1.x̂0 ≈ zeros(4)
@test_skip @allocations(preparestate!(lo1, y)) == 0
@test_skip @allocations(updatestate!(lo1, u, y)) == 0
@test @allocations(preparestate!(lo1, y)) == 0
@test @allocations(updatestate!(lo1, u, y)) == 0
preparestate!(lo1, y)
@test evaloutput(lo1) ≈ lo1() ≈ [50, 30]
@test evaloutput(lo1, d) ≈ lo1(d) ≈ [50, 30]
@test_skip @allocations(evaloutput(lo1, d)) == 0
@test @allocations(evaloutput(lo1, d)) == 0
@test initstate!(lo1, [10, 50], [50, 30+1]) ≈ [zeros(3); [1]]
setstate!(lo1, [1,2,3,4])
@test lo1.x̂0 ≈ [1,2,3,4]
Expand Down Expand Up @@ -457,11 +457,11 @@ end
@test updatestate!(internalmodel1, u, y, d) ≈ zeros(2)
@test internalmodel1.x̂d ≈ internalmodel1.x̂0 ≈ zeros(2)
@test internalmodel1.x̂s ≈ ones(2)
@test_skip @allocations(preparestate!(internalmodel1, y)) == 0
@test_skip @allocations(updatestate!(internalmodel1, u, y)) == 0
@test @allocations(preparestate!(internalmodel1, y)) == 0
@test @allocations(updatestate!(internalmodel1, u, y)) == 0
preparestate!(internalmodel1, y)
@test evaloutput(internalmodel1, d) ≈ [51,31]
@test_skip @allocations(evaloutput(internalmodel1, d)) == 0
@test @allocations(evaloutput(internalmodel1, d)) == 0
@test initstate!(internalmodel1, [10, 50], [50, 30]) ≈ zeros(2)
@test internalmodel1.x̂s ≈ zeros(2)
setstate!(internalmodel1, [1,2])
Expand Down Expand Up @@ -593,12 +593,12 @@ end
preparestate!(ukf1, y)
@test updatestate!(ukf1, u, y, d) ≈ zeros(4) atol=1e-9
@test ukf1.x̂0 ≈ zeros(4) atol=1e-9
@test_skip @allocations(preparestate!(ukf1, y)) == 0
@test_skip @allocations(updatestate!(ukf1, u, y)) == 0
@test @allocations(preparestate!(ukf1, y)) == 0
@test @allocations(updatestate!(ukf1, u, y)) == 0
preparestate!(ukf1, y)
@test evaloutput(ukf1) ≈ ukf1() ≈ [50, 30]
@test evaloutput(ukf1, d) ≈ ukf1(d) ≈ [50, 30]
@test_skip @allocations(evaloutput(ukf1, d)) == 0
@test @allocations(evaloutput(ukf1, d)) == 0
@test initstate!(ukf1, [10, 50], [50, 30+1]) ≈ zeros(4) atol=1e-9
setstate!(ukf1, [1,2,3,4], diagm(.1:.1:.4))
@test ukf1.x̂0 ≈ [1,2,3,4]
Expand Down Expand Up @@ -752,12 +752,12 @@ end
preparestate!(ekf1, y)
@test updatestate!(ekf1, u, y, d) ≈ zeros(4) atol=1e-9
@test ekf1.x̂0 ≈ zeros(4) atol=1e-9
@test_skip @allocations(preparestate!(ekf1, y)) == 0
@test_skip @allocations(updatestate!(ekf1, u, y)) == 0
@test @allocations(preparestate!(ekf1, y)) == 0
@test @allocations(updatestate!(ekf1, u, y)) == 0
preparestate!(ekf1, y)
@test evaloutput(ekf1) ≈ ekf1() ≈ [50, 30]
@test evaloutput(ekf1, d) ≈ ekf1(d) ≈ [50, 30]
@test_skip @allocations(evaloutput(ekf1, d)) == 0
@test @allocations(evaloutput(ekf1, d)) == 0
@test initstate!(ekf1, [10, 50], [50, 30+1]) ≈ zeros(4);
setstate!(ekf1, [1,2,3,4], diagm(.1:.1:.4))
@test ekf1.x̂0 ≈ [1,2,3,4]
Expand Down
2 changes: 1 addition & 1 deletion test/3_test_predictive_control.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ end
@test u ≈ [1] atol=1e-2
u = mpc1(r)
@test u ≈ [1] atol=1e-2
@test_skip @allocations(moveinput!(mpc1, r)) == 0
@test @allocations(moveinput!(mpc1, r)) == 0
info = getinfo(mpc1)
@test info[:u] ≈ u
@test info[:Ŷ][end] ≈ r[1] atol=1e-2
Expand Down
Loading