1
1
export genplots, getexamples, runplotgen
2
2
3
- @doc """ results = runplotgen()
3
+ """ results = runplotgen()
4
4
Run full generation of the plots needed for the tests in ControlSystems.jl
5
- """ ->
5
+ """
6
6
function runplotgen ()
7
7
funcs, refs, eps = getexamples ()
8
8
genplots (funcs, refs, eps= eps)
9
9
end
10
10
11
- @doc """ results = genplots(funcs, refs; eps, kwargs...)
11
+ """ results = genplots(funcs, refs; eps, kwargs...)
12
12
Generate the plots needed for the tests in ControlSystems.jl
13
- """ ->
13
+ """
14
14
function genplots (funcs, refs; eps= 0.01 * ones (length (refs)), kwargs... )
15
15
ENV [" MPLBACKEND" ] = " Agg"
16
- results = Array {VisualRegressionTests.VisualTestResult,1} (length (refs))
16
+ results = Array {VisualRegressionTests.VisualTestResult,1} (undef, length (refs))
17
17
# Run/generate tests
18
18
for (i,ref) in enumerate (refs)
19
19
testf (fn) = png (funcs[i](), fn)
20
- results[i] = test_images (VisualTest (testf, ref); eps = eps[i], kwargs... )
20
+ results[i] = test_images (VisualTest (testf, ref); tol = eps[i], kwargs... )
21
21
end
22
22
results
23
23
end
24
24
25
- @doc """ funcs, refs, eps = getexamples()
25
+ """ funcs, refs, eps = getexamples()
26
26
Get the example functions and locations of reference plots needed for the tests in ControlSystems.jl
27
- """ ->
27
+ """
28
28
function getexamples ()
29
- tf1 = tf ([1 ],[1 ,1 ], inputnames = [ " Inp1 " ], outputnames = [ " Out1 " ] )
30
- tf2 = tf ([1 / 5 ,2 ],[1 ,1 ,1 ], inputnames = [ " Inp2 " ], outputnames = [ " Out1 " ] )
29
+ tf1 = tf ([1 ],[1 ,1 ])
30
+ tf2 = tf ([1 / 5 ,2 ],[1 ,1 ,1 ])
31
31
sys = [tf1 tf2]
32
- sysss = ss ([- 1 2 ; 0 1 ], [1 0 ; 1 1 ], [1 0 ; 0 1 ], [0.1 0 ; 0 - 0.2 ],
33
- inputnames= [" MyIn1" , " MyIn2" ], statenames= [" State1" , " State2" ])
32
+ sysss = ss ([- 1 2 ; 0 1 ], [1 0 ; 1 1 ], [1 0 ; 0 1 ], [0.1 0 ; 0 - 0.2 ])
34
33
35
- ws = logspace (- 2 ,2 , 200 )
34
+ ws = 10.0 .^ range (- 2 ,stop = 2 ,length = 200 )
36
35
ts = 0 : 0.01 : 5
37
36
bodegen () = begin
38
37
setPlotScale (" dB" )
@@ -45,7 +44,7 @@ function getexamples()
45
44
46
45
stepgen () = stepplot (sys, ts[end ], ts[2 ]- ts[1 ], l= (:dash , 4 ))
47
46
impulsegen () = impulseplot (sys, ts[end ], ts[2 ]- ts[1 ], l= :blue )
48
- L = lqr (sysss. A, sysss. B, eye ( 2 ), eye ( 2 ) )
47
+ L = lqr (sysss. A, sysss. B, [ 1 0 ; 0 1 ], [ 1 0 ; 0 1 ] )
49
48
lsimgen () = lsimplot (sysss, (x,i)-> - L* x, ts, [1 ;2 ])
50
49
51
50
margingen () = marginplot ([tf1, tf2], ws)
@@ -56,11 +55,11 @@ function getexamples()
56
55
pzmapgen () = pzmap (tf2, xlims= (- 15 ,5 ))
57
56
rlocusgen () = rlocusplot (tf2)
58
57
59
- plotsdir = Pkg . dir ( " ControlExamplePlots" ) * " / src/ figures/ "
58
+ plotsdir = joinpath ( dirname ( pathof ( ControlExamplePlots)), " .. " , " src" , " figures" )
60
59
refs = [" bode.png" , " nyquist.png" , " sigma.png" , " nichols.png" , " step.png" ,
61
60
" impulse.png" , " lsim.png" , " margin.png" , " gangoffour.png" , " pzmap.png" , " rlocus.png" ]
62
61
funcs = [bodegen, nyquistgen, sigmagen, nicholsgen, stepgen,
63
62
impulsegen, lsimgen, margingen, gangoffourgen, pzmapgen, rlocusgen]
64
63
eps = 0.001 * ones (length (refs));
65
- funcs, map (s -> plotsdir* s , refs), eps
64
+ funcs, map (s -> joinpath ( plotsdir,s) , refs), eps
66
65
end
0 commit comments