Skip to content

Commit

Permalink
Test Coverage II.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Jul 12, 2023
1 parent ab92afc commit 898977a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/plans/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ end
function show(
io::IO, t::Tuple{<:SimpleManifoldCachedObjective,S}
) where {S<:AbstractManoptSolverState}
return print(io, "$(t[2])\n\n$(t[1])")
return print(io, "$(t[2])\n\n$(status_summary(t[1]))")
end
function show(io::IO, mco::ManifoldCachedObjective)
return print(io, "$(status_summary(mco))")
Expand All @@ -803,8 +803,9 @@ function show(
end

function status_summary(smco::SimpleManifoldCachedObjective)
s = "## Cache\nA `SimpleManifoldCachedObjective` to cache one point and one tangent vector for the iterate and gradient, respectively\n"
s = "## Cache\nA `SimpleManifoldCachedObjective` to cache one point and one tangent vector for the iterate and gradient, respectively"
s2 = status_summary(smco.objective)
length(s2) > 0 && (s2 = "\n$(s2)")
return "$(s)$(s2)"
end
function status_summary(mco::ManifoldCachedObjective)
Expand Down
7 changes: 7 additions & 0 deletions test/plans/test_cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ end
sco1 = Manopt.SimpleManifoldCachedObjective(M, mgoa; p=p)
@test repr(sco1) == "SimpleManifoldCachedObjective{AllocatingEvaluation,$(mgoa)}"
@test startswith(repr((sco1, 1.0)), "## Cache\nA `SimpleManifoldCachedObjective`")
@test startswith(
repr((sco1, DummyState())),
"DummyState(Float64[])\n\n## Cache\nA `SimpleManifoldCachedObjective`",
)
# We evaluated on init -> 1
@test sco1.objective.gradient!!.i == 1
@test sco1.objective.cost.i == 1
Expand Down Expand Up @@ -180,6 +184,9 @@ end
co = ManifoldCountObjective(M, o, [:Cost, :Gradient])
lco = objective_cache_factory(M, co, (:LRU, [:Cost, :Gradient]))
@test startswith(repr(lco), "## Cache\n * ")
@test startswith(
repr((lco, DummyState())), "DummyState(Float64[])\n\n## Cache\n * "
)
ro = DummyDecoratedObjective(o)
#indecorated works as well
lco2 = objective_cache_factory(M, o, (:LRU, [:Cost, :Gradient]))
Expand Down

0 comments on commit 898977a

Please sign in to comment.