Skip to content

Commit 04bdc09

Browse files
committed
plan / state / codecov++
1 parent dad7df2 commit 04bdc09

3 files changed

Lines changed: 20 additions & 15 deletions

File tree

src/plans/solver_state.jl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ abstract type AbstractManoptSolverState end
1717

1818
function Base.show(io::IO, ::MIME"text/plain", ams::AbstractManoptSolverState)
1919
multiline = get(io, :multiline, true)
20-
if multiline
21-
return status_summary(io, ams)
22-
else
23-
show(io, ams)
24-
end
20+
return multiline ? status_summary(io, ams) : show(io, ams)
2521
end
2622

2723
"""
@@ -128,8 +124,8 @@ should be returned at the end of a solver instead of the usual minimizer.
128124
struct ReturnSolverState{S <: AbstractManoptSolverState} <: AbstractManoptSolverState
129125
state::S
130126
end
131-
status_summary(rst::ReturnSolverState) = status_summary(rst.state)
132-
show(io::IO, rst::ReturnSolverState) = print(io, "ReturnSolverState($(rst.state))")
127+
status_summary(rst::ReturnSolverState; context::Symbol = :default) = status_summary(rst.state; context = context)
128+
show(io::IO, rst::ReturnSolverState) = print(io, "ReturnSolverState(", rst.state, ")")
133129
dispatch_state_decorator(::ReturnSolverState) = Val(true)
134130

135131
"""
@@ -317,9 +313,11 @@ for example within the [`DebugSolverState`](@ref) or within the [`RecordSolverSt
317313
abstract type AbstractStateAction end
318314

319315
status_summary(asa::AbstractStateAction; context::Symbol = :default) = repr(asa)
320-
status_summary(io::IO, asa::AbstractStateAction; context::Symbol = :default) = print(io, status_summary(asa; context = context))
321316

322-
Base.show(io::IO, ::MIME"text/plain", asa::AbstractStateAction) = status_summary(io::IO, asa; context = :default)
317+
function Base.show(io::IO, ::MIME"text/plain", asa::AbstractStateAction)
318+
multiline = get(io, :multiline, true)
319+
return multiline ? status_summary(io, asa) : show(io, asa)
320+
end
323321

324322
mutable struct StorageRef{T}
325323
x::T

test/plans/test_state.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ struct NoIterateState <: AbstractManoptSolverState end
99
pr = Manopt.Test.DummyProblem{typeof(M)}()
1010
s = Manopt.Test.DummyState()
1111
@test repr(Manopt.ReturnSolverState(s)) == "ReturnSolverState($s)"
12-
@test Manopt.status_summary(Manopt.ReturnSolverState(s)) ==
13-
"A Manopt Test state with storage Float64[]"
12+
srst = "A Manopt Test state with storage Float64[]"
13+
@test Manopt.status_summary(Manopt.ReturnSolverState(s)) == srst
14+
io = IOBuffer()
15+
show(io, MIME"text/plain"(), Manopt.ReturnSolverState(s))
16+
@test startswith(String(take!(io)), srst)
17+
1418
a = ArmijoLinesearch(; initial_stepsize = 1.0)(M)
1519
@test get_last_stepsize(a) == 1.0
1620
@test get_initial_stepsize(a) == 1.0

test/plans/test_storage.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ using Test, Manopt, ManifoldsBase, Manifolds
1010
X_zero = zero_vector(M, p)
1111

1212
st = GradientDescentState(
13-
M;
14-
p = p,
15-
stopping_criterion = StopAfterIteration(20),
16-
stepsize = Manopt.ConstantStepsize(M),
13+
M; p = p,
14+
stopping_criterion = StopAfterIteration(20), stepsize = Manopt.ConstantStepsize(M),
1715
)
1816
f(M, q) = distance(M, q, p) .^ 2
1917
grad_f(M, q) = -2 * log(M, q, p)
2018
mp = DefaultManoptProblem(M, ManifoldGradientObjective(f, grad_f))
2119

2220
a = StoreStateAction(M; store_fields = [:p, :X])
2321

22+
@test Manopt.status_summary(a) == repr(a)
23+
io = IOBuffer()
24+
show(io, MIME"text/plain"(), a)
25+
@test String(take!(io)) == repr(a)
26+
2427
@test !has_storage(a, Manopt.PointStorageKey(:p))
2528
@test !has_storage(a, Manopt.VectorStorageKey(:X))
2629
update_storage!(a, mp, st)

0 commit comments

Comments
 (0)