Skip to content

Commit

Permalink
Remove some deprecated old code and increase code cov
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Aug 14, 2024
1 parent 86c6742 commit 08a0511
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/plans/constrained_plan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -571,24 +571,6 @@ within the [`ConstrainedManifoldObjective`](@ref).
"""
get_unconstrained_objective(co::ConstrainedManifoldObjective) = co.objective

function get_constraints(mp::AbstractManoptProblem, p)
Base.depwarn(
"get_constraints will be removed in a future release, use `get_equality_constraint($mp, $p, :)` and `get_inequality_constraint($mp, $p, :)`, respectively",
:get_constraints,
)
return [
get_inequality_constraint(get_manifold(mp), get_objective(mp), p, :),
get_equality_constraint(get_manifold(mp), get_objective(mp), p, :),
]
end
function get_constraints(M::AbstractManifold, co::ConstrainedManifoldObjective, p)
Base.depwarn(
"get_constraints will be removed in a future release, use `get_equality_constraint($M, $co, $p, :)` and `get_inequality_constraint($M, $co, $p, :)`, respectively",
:get_constraints,
)
return [get_inequality_constraint(M, co, p, :), get_equality_constraint(M, co, p, :)]
end

function get_cost(M::AbstractManifold, co::ConstrainedManifoldObjective, p)
return get_cost(M, co.objective, p)
end
Expand Down
3 changes: 3 additions & 0 deletions test/plans/test_state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct NoIterateState <: AbstractManoptSolverState end
s2 = NoIterateState()
@test_throws ErrorException get_iterate(s2)
end

@testset "Iteration and Gradient setters" begin
M = Euclidean(3)
s1 = NelderMeadState(M)
Expand All @@ -89,10 +90,12 @@ struct NoIterateState <: AbstractManoptSolverState end
@test d2.state.X == ones(3)
@test get_stopping_criterion(d2) === s2.stop
end

@testset "Closed Form State" begin
@test Manopt.ClosedFormSubSolverState() isa
Manopt.ClosedFormSubSolverState{AllocatingEvaluation}
end

@testset "Generic Objective and State solver returns" begin
f(M, p) = 1
o = ManifoldCostObjective(f)
Expand Down
24 changes: 24 additions & 0 deletions test/plans/test_storage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,28 @@ using Test, Manopt, ManifoldsBase, Manifolds
end

@test Manopt.extract_type_from_namedtuple(typeof((; a=10, b='a')), Val(:c)) === Any

@testset "StorageRef for numbers" begin
# Since we wrap now earlier, these might indeed no longer be actually used
M = ManifoldsBase.DefaultManifold()
q = Manopt._storage_copy_point(M, 1.0)
copyto!(q, 2.0)
@test q.x == 2.0
Y = Manopt._storage_copy_vector(M, 3.0)
st = Manopt.StoreStateAction(
M; p_init=1.0, X_init=2.0, store_points=Tuple{:p}, store_vectors=Tuple{:X}
)
Manopt.get_storage(st, Manopt.VectorStorageKey(:X)) == 2.0
Manopt.get_storage(st, Manopt.PointStorageKey(:p)) == 1.0
end
@testset "Store swarm" begin
M = ManifoldsBase.DefaultManifold(2)
A = [[1.0, 2.0], [3.0, 4.0]]
pss = ParticleSwarmState(M, A, [[5.0, 6.0], [7.0, 8.0]])
a = StoreStateAction(M; store_fields=[:Population])
f(M, q) = distance(M, q, [1.2, 1.3]) .^ 2
mp = DefaultManoptProblem(M, ManifoldCostObjective(f))
update_storage!(a, mp, pss)
@test get_storage(a, :Population) == A
end
end
7 changes: 7 additions & 0 deletions test/solvers/test_interior_point_Newton.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
using Manifolds, Manopt, LinearAlgebra, Random, Test

@testset "Interior Point Newton Solver" begin
@testset "StepsizeState" begin
M = Manifolds.Sphere(2)
a = StepsizeState(M)
b = StepsizeState(a.p, a.X)
@test a.p === b.p
@test a.X === b.X
end
@testset "A solver run on the Sphere" begin
# We can take a look at debug prints of one run and plot the result
# on CI and when running with ] test Manopt, both have to be set to false.
Expand Down

0 comments on commit 08a0511

Please sign in to comment.