Skip to content

Commit 44b4323

Browse files
committed
Make convergence history show a summary
1 parent 9383e1d commit 44b4323

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/history.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using RecipesBase
22

3-
import Base: getindex, setindex!, push!, keys
3+
import Base: getindex, setindex!, push!, keys, show
44

55
export ConvergenceHistory
66
export nprods, niters, nrests
@@ -90,6 +90,11 @@ const RestartedHistory{T} = ConvergenceHistory{T, Int}
9090
# Functions #
9191
#############
9292

93+
function show(io::IO, ch::ConvergenceHistory)
94+
print(io, ch.isconverged ? "Converged" : "Not converged",
95+
" after ", ch.iters, " iterations.")
96+
end
97+
9398
"""
9499
getindex(ch, s)
95100

test/history.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ using Base.Test
88

99
RecipesBase.is_key_supported(k::Symbol) = k == :sep ? false : true
1010

11+
begin
12+
history = ConvergenceHistory(partial = false)
13+
history.iters = 3
14+
history.isconverged = true
15+
@test string(history) == "Converged after 3 iterations."
16+
history.isconverged = false
17+
@test string(history) == "Not converged after 3 iterations."
18+
end
19+
1120
# No plottables
1221
begin
1322
history = ConvergenceHistory(partial = false)

0 commit comments

Comments
 (0)