Skip to content

Commit c518f1b

Browse files
committed
unify summaries.
1 parent da9f1e4 commit c518f1b

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/stopping_criterion.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ function Base.summary(
464464
)
465465
has_stopped = (stopping_criterion_state.at_iteration >= 0)
466466
s = has_stopped ? "reached" : "not reached"
467-
return print(io, "Max Iteration $(stop_after_iteration.max_iterations):\t$s")
467+
return print(io, "Max Iteration $(stop_after_iteration.max_iterations): $s")
468468
end
469469

470470
"""
@@ -572,6 +572,6 @@ function Base.summary(
572572
)
573573
has_stopped = (stopping_criterion_state.at_iteration >= 0)
574574
s = has_stopped ? "reached" : "not reached"
575-
return print(io, "stopped after $(stop_after.threshold):\t$s")
575+
return print(io, "stopped after $(stop_after.threshold): $s")
576576
end
577577
indicates_convergence(stop_after::StopAfter) = false

test/stopping_criterion.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,27 @@ problem = AIT.DummyProblem()
1717
alg_state = AIT.DummyState(s1_state, 1)
1818
@test is_finished(problem, algorithm, state_finished)
1919
@test !is_finished(problem, algorithm, alg_state)
20+
# Fake a stop:
21+
s1_state.at_iteration = 2
22+
@test startswith(get_reason(s1, s1_state), "At iteration 2")
23+
@test endswith(summary(s1, s1_state), " reached")
2024
end
2125

2226
@testset "StopAfter" begin
2327
s1 = StopAfter(Second(1))
2428
@test s1 isa StoppingCriterion
2529
@test string(s1) == "StopAfter(Second(1))"
30+
@test_throws ArgumentError StopAfter(Second(-1))
2631

2732
algorithm = AIT.DummyAlgorithm(s1)
2833
s1_state = initialize_state(problem, algorithm, s1)
2934
alg_state = AIT.DummyState(s1_state, 1)
3035
@test !is_finished(problem, algorithm, alg_state)
3136
s1_state.time = Second(2)
3237
@test is_finished(problem, algorithm, alg_state)
38+
s1_state.at_iteration = 2
39+
@test startswith(get_reason(s1, s1_state), "After iteration 2")
40+
@test endswith(summary(s1, s1_state), " reached")
3341
end
3442

3543
@testset "StopWhenAll" begin

0 commit comments

Comments
 (0)