|
1 | 1 | using IterativeSolvers
|
| 2 | +using RecipesBase |
| 3 | +using Base.Test |
2 | 4 |
|
3 | 5 | @testset "ConvergenceHistory" begin
|
4 | 6 |
|
| 7 | + const KW = Dict{Symbol, Any} |
| 8 | + |
| 9 | + RecipesBase.is_key_supported(k::Symbol) = k == :sep ? false : true |
| 10 | + |
| 11 | + # No plottables |
| 12 | + begin |
| 13 | + history = ConvergenceHistory(partial = false) |
| 14 | + @test_throws ErrorException RecipesBase.apply_recipe(KW(), history) |
| 15 | + end |
| 16 | + |
| 17 | + # Without restart markers |
| 18 | + begin |
| 19 | + history = ConvergenceHistory(partial = false) |
| 20 | + history.iters = 3 |
| 21 | + history.data[:resnorm] = [10.0, 3.0, 0.1] |
| 22 | + |
| 23 | + plots = ( |
| 24 | + RecipesBase.apply_recipe(KW(), history), |
| 25 | + RecipesBase.apply_recipe(KW(), history, :resnorm) |
| 26 | + ) |
| 27 | + |
| 28 | + for data in plots |
| 29 | + @test length(data) == 1 |
| 30 | + @test data[1].d[:label] == "resnorm" |
| 31 | + @test data[1].d[:seriestype] == :line |
| 32 | + end |
| 33 | + end |
| 34 | + |
| 35 | + # With restart markers |
| 36 | + begin |
| 37 | + history = ConvergenceHistory(partial = false, restart = 2) |
| 38 | + history.iters = 3 |
| 39 | + history.data[:resnorm] = [10.0, 3.0, 0.1] |
| 40 | + |
| 41 | + plots = ( |
| 42 | + RecipesBase.apply_recipe(KW(), history), |
| 43 | + RecipesBase.apply_recipe(KW(), history, :resnorm) |
| 44 | + ) |
| 45 | + |
| 46 | + for data in plots |
| 47 | + @test length(data) == 2 |
| 48 | + @test data[2].d[:linecolor] == :white |
| 49 | + end |
| 50 | + end |
| 51 | + |
| 52 | + # Custom color |
| 53 | + begin |
| 54 | + history = ConvergenceHistory(partial = false, restart = 2) |
| 55 | + history.iters = 3 |
| 56 | + history.data[:resnorm] = [10.0, 3.0, 0.1] |
| 57 | + |
| 58 | + plots = ( |
| 59 | + RecipesBase.apply_recipe(KW(:sep => :red), history), |
| 60 | + RecipesBase.apply_recipe(KW(:sep => :red), history, :resnorm) |
| 61 | + ) |
| 62 | + |
| 63 | + for data in plots |
| 64 | + @test length(data) == 2 |
| 65 | + @test data[2].d[:linecolor] == :red |
| 66 | + end |
| 67 | + end |
5 | 68 | end
|
0 commit comments