A test suite for Lie groups
In the sub module LieGroups.Test, we provide a test suite for Lie groups and Lie group actions.
LieGroups.Test โ Module
LieGroups.TestThis module provides tools and dummy structures to test functionality provided within LieGroups.jl.
For every test function, several interactions to other functions can be activated.
The following functions are expected to be available, since their defaults just pass through to the manifold
is_pointboth on the Lie groupGand the Lie algebra๐คisapprox(G, g, h)andisapprox(๐ค, X, Y)copy(G, g)norm(๐ค, X)
Most functionality only gets loaded once Test.jl is loaded as well, i.e. that the functions are populated with methods by the extension.
Test suites
LieGroups.Test.test_lie_group โ Function
LieGroups.Test.test_lie_group(G::AbstractLieGroup, properties::Dict, expectations::Dict)Test the AbstractLieGroup $G$ based on a Dict of properties and a Dict of expectations.
Possible properties are
:Aliasedis a boolean (same as:Mutatingby default) whether to test the mutating variants with aliased input:Functionsis a vector of all defined functions forGNote that iffis in:Functions, andf!makes sense, for example forcompose, it is assumed that both are defined.:Pointsis a vector of at least 2 points onG, the first is not allowed to be the identity numerically:Vectorsis a vector of at least 2 elements from the Lie algebra๐คogG:Mutatingis a boolean (trueby default) whether to test the mutating variants of functions or not.:Nameis a name of the test. If not provided, defaults to"$G":Rngis a random number generator, if provided, the random functions are tested with this generator as well
Possible expectations are
:adjointfor the result of'conjugatein the case wherediff_conjugateis not implemented:atol => 0.0a global absolute tolerance:atols -> Dict()a dictionaryfunction -> atolfor specific function tested.:conjugatefor the result of `conjugate:conjugate_default => falseto activate the test of the default implementation ofconjugate:diff_invfor the result ofdiff_invwith respect to the first point and the first vector.:diff_left_composefor the result ofdiff_left_composewith respect to the first two points and the first vector.:diff_right_composefor the result ofdiff_right_composewith respect to the first two points and the first vector.:inv_left_composefor the result ofinv_left_right_composewith respect to the first two points:inv_right_composefor the result ofinv_right_composewith respect to the first two points:repris a sting one gets fromrepr(G):veefor the result ofvee(G, X)whereXis the first of the vectors
LieGroups.Test.test_group_action โ Function
LieGroups.Test.test_group_action(A::GroupAction, properties::Dict, expectations::Dict)Test the GroupAction $A$ based on a Dict of properties and a Dict of expectations.
Possible properties are
:AlgebraVectorsis a vector of at least 3 elements from the Lie algebra๐คofG:Functionsis a vector of all defined functions forGNote that iffis in:Functions, andf!makes sense, for example forcompose, it is assumed that both are defined.:GroupPointsis a vector of at least three points onG, the first is not allowed to be the identity numerically:ManifoldPointsis a vector of at least three points onM:TangentVectorsis a vector of at least three tangent vectors onM, each in the tangent space of the corresponding:ManifoldPoint:Mutatingis a boolean (trueby default) whether to test the mutating variants of functions or not.:Nameis a name of the test. If not provided, defaults to"$G"
Possible expectations are
:applyfor the result ofapplyon the first group and manifold point:diff_applyfor the result ofapplyon the first group and manifold point together with the first tangent vector:atola global absolute tolerance, defaults to1e-8:groupis theAbstractLieGroupdescribing the action:manifoldis theAbstractManifoldthe action acts upon:repris a sting one gets fromrepr(G)
Single test functions
LieGroups.Test.test_apply โ Function
LieGroups.Test.test_apply(A::GroupAction, g, p; expected=missing)Test apply.
Keyword arguments
test_aliased::Bool=test_mutating: test aliased input on the mutating variants.expected=missing: the result of the application of the group action.test_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_adjoint โ Function
LieGroups.Test.test_adjoint(G::AbstractLieGroup, g, X; kwargs...)Test adjoint function for a given Lie group element g and a Lie Algebra vector X
Keyword arguments
test_aliased::Bool=test_mutating: test aliased input on the mutating variants.expected=missingprovide the value expected. If none is provided, the default fromdiff_conjugateis usedtest_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_compose โ Function
LieGroups.Test.test_compose(G::AbstractLieGroup, g, h; kwargs...)Test compose for given Lie group elements g, h.
Keyword arguments
atol::Real=0: the absolute tolerance for the tests of zero-vectorstest_aliased::Bool=test_mutating: test aliased input on the mutating variants.test_identity::Bool=true: test that composing with the identity yields the identity (requiresidentity_element)test_inverse::Bool=true: test thatg^{-1}gis the identity (requiresinv,inv!, andis_identity)test_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_conjugate โ Function
LieGroups.Test.test_conjugate(G::AbstractLieGroup, g, h; expected=missing)Test conjugate.
Keyword arguments
expected=missing: the result of the conjugate with a concrete expected result.test_default=false: Since the conjugate can be computed usingcomposeandinvโ this test can check that this default provides the same resulttest_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_copyto โ Function
LieGroups.Test.test_copyto(G::LieGroup, g)Test that copyto! works also when copying over an Identity.
The point g can be any point but the identity_element. The group has to be a mutating one, that is, not work on isbit types.
LieGroups.Test.test_diff_apply โ Function
LieGroups.Test.test_diff_apply(A::GroupAction, g, p, X; expected=missing)Test diff_apply.
Keyword arguments
expected=missing: the result of the application of the group action.test_aliased::Bool=test_mutating: test aliased input on the mutating variants.test_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_diff_conjugate โ Function
LieGroups.Test.test_diff_conjugate(A::GroupAction, g, p, X; expected=missing)Test diff_conjugate
LieGroups.Test.test_diff_group_apply โ Function
LieGroups.Test.test_diff_group_apply(A::GroupAction, g, p, X; expected=missing)Test diff_group_apply.
Keyword arguments
expected=missing: the result of the application of the group action.test_aliased::Bool=test_mutating: test aliased input on the mutating variants.test_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_diff_inv โ Function
LieGroups.Test.test_diff_inv(G::AbstractLieGroup, g, X; expected=missing)Test diff_inv.
Keyword arguments
expected=missing: the result of the differential of the inverse, if not provided, only consistency between the allocating and the in-place variant is checked.test_aliased::Bool=test_mutating: test aliased input on the mutating variants.test_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_diff_left_compose โ Function
LieGroups.Test.test_diff_left_compose(G::AbstractLieGroup, g, h, X; expected=missing)Test diff_left_compose.
Keyword arguments
expected=missing: the result of the differential of the compose's left argument, if not provided, only consistency between the allocating and the in-place variant is checked.test_aliased::Bool=test_mutating: test aliased input on the mutating variants.test_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_diff_right_compose โ Function
LieGroups.Test.test_diff_right_compose(G::AbstractLieGroup, g, h, X; expected=missing)Test diff_right_compose.
Keyword arguments
expected=missing: the result of the differential of the compose's right argument, if not provided, only consistency between the allocating and the in-place variant is checked.test_aliased::Bool=test_mutating: test aliased input on the mutating variants.test_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_exp_log โ Function
LieGroups.Test.test_exp_log(G::AbstractLieGroup, g, h, X)Test exp and log for given Lie group elements g, h and a vector X from the Lie Algebra.
Keyword arguments
atol::Real=0: the absolute tolerance for the tests of zero-vectorstest_aliased::Bool=test_mutating: test aliased input on the mutating variants.test_exp::Bool=true: test the exponential map yields a point onGtest_log::Bool=true: test the logarithmic map.test_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_identity โ Function
LieGroups.Test.test_is_identity(G::AbstractLieGroup, g)Test that the Identity returns that is_identity is true and that it is a point
LieGroups.Test.test_hat_vee โ Function
LieGroups.Test.test_hat_vee(G::AbstractLieGroup, g, X; kwargs...)Test hat and vee for given Lie group element g and a Lie Algebra vector X.
Keyword arguments
expected_value=missing: the expected value ofvee(G,X)test_mutating::Bool=true: test the mutating functionstest_vee::Bool=true: test the vee functiontest_hat::Bool=true: test the hat function
LieGroups.Test.test_identity_element โ Function
LieGroups.Test.test_identity_element(G::AbstractLieGroup; kwargs...)Test the function identity_element(G) or identity_element(G, T).
Keyword arguments
expected_value=missing: the expected value of the call toidentity_elementidentity_type=missing; provide a typeT? to testidentity_element(G, T)the case ofnothing` calls the one-parameter versiontest_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_injectivity_radius โ Function
LieGroups.Test.test_injectivity_radius(G::AbstractLieGroup; kwargs...)Test the function injectivity_radius.
Keyword arguments
expected=missing: expected value for global injectivity radius.
LieGroups.Test.test_inner โ Function
LieGroups.Test.test_inner(G::AbstractLieGroup, g, X, Y; expected=missing)Test inner.
Keyword arguments
expected=missing: the result of the lie bracket if not provided, nonnegativity of inner products of vectors with themselves is tested as well as consistency with the inner product at the identity element called on the manifold.
LieGroups.Test.test_inv โ Function
LieGroups.Test.test_inv(G::AbstractLieGroup, g)Test the inverse function, both the allocating and the in-place variant, and that the double inverse is the identity.
Keyword arguments
test_aliased::Bool=test_mutating: test aliased input on the mutating variants.test_mutating::Bool=true: test the mutating functionstest_identity::Bool=true: test thatinv(e) == eexpected=missing: the expected value ofinv(G, g)atol::Real=0: the absolute tolerance for the tests.
LieGroups.Test.test_inv_compose โ Function
LieGroups.Test.test_inv_compose(G::AbstractLieGroup, g, h, X; kwargs...)Test the special functions combining inv and compose, inv_left_compose and inv_right_compose. For these tests both compose and inv are required.
Keyword arguments
test_left::Bool=true: test $g^{-1}โh$test_mutating::Bool=true: test the mutating functionstest_right::Bool=true: test $gโh^{-1}$
LieGroups.Test.test_is_flat โ Function
LieGroups.Test.test_is_flat(G::AbstractLieGroup; kwargs...)Test the function is_flat.
Keyword arguments
expected=missing: expected value for flatness.
LieGroups.Test.test_jacobian_conjugate โ Function
LieGroups.Test.test_jacobian_conjugate(G::AbstractLieGroup, g, h, basis=DefaultLieAlgebraOrthogonalBasis();
expected=missing,
test_mutating=true,
kwargs...
)Test jacobian_conjugate. The kwargs... are passed down to the isapprox check for the expeced value
LieGroups.Test.test_jacobian_exp โ Function
LieGroups.Test.test_jacobian_exp(
G::AbstractLieGroup, g, X;
basis = DefaultLieAlgebraOrthogonalBasis(),
expected = missing,
test_mutating = true,
kwargs...
)test jacobian_exp.
LieGroups.Test.test_lie_bracket โ Function
LieGroups.Test.test_lie_bracket(G::AbstractLieGroup, X, Y; expected=missing)Test lie_bracket.
Keyword arguments
expected=missing: the result of the lie bracket if not provided, only consistency between the allocating and the in-place variant is checked.test_mutating::Bool=true: test the mutating functions
LieGroups.Test.test_norm โ Function
LieGroups.Test.test_norm(G::AbstractLieGroup, g, X; expected=missing)Test norm on the Lie Algebra and the pass-through from the Lie group.
Keyword arguments
expected=missing: the result of the lie bracket if not provided, nonnegativity of inner products of vectors with themselves is tested as well as consistency with the inner product at the identity element called on the manifold.
LieGroups.Test.test_push_pull_tangent โ Function
LieGroups.Test.test_push_pull_tangent(G::AbstractLieGroup, g, X; expected=missing, atol=0)Test push_forward_tangent and pull_back_tangent.
Keyword arguments
atol=0: the absolute tolerance for the tests of zero-vectorstest_mutating::Bool=true: test the mutating functionstest_pull_back::Bool=true: test the pull-back of a tangent vector. If only this is set, a zero vector is pulled-back.test_push_forward::Bool=true: test the push-forward of a tangent vector. If only this is set,Xis pushed forward and has to be a valid tangent vector.
LieGroups.Test.test_rand โ Function
LieGroups.Test.test_rand(G::AbstractLieGroup)Test the random function, both the allocating and the in-place variant, as well as the variant with an rng, if one is provided.
both the random point and the random tangent vector variants are tested.
Keyword arguments
test_mutating::Bool=true: test the mutating functionsrng=missing: test with a specific random number generator
LieGroups.Test.test_show โ Function
LieGroups.Test.test_show(G, repr_string::AbstractString)Test that show methods work as expected. For now this (only) checks that "$G" yields the repr_string.
Requires show (or repr) to be implemented.
Helper functions
LieGroups.Test.rotation_matrix โ Function
rotate_matrix(n, k1, k2, ฮฑ)Generate a rotation matrix in $โ^{nรn}$ with a rotation about $ฮฑ$ (in radians) in the $k_1-k_2$-plane.