From c35aa83f794d5c345ac887bd70ff5af5caa41747 Mon Sep 17 00:00:00 2001 From: Ronny Bergmann Date: Fri, 15 Dec 2023 11:42:02 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Mateusz Baran --- src/groups/addition_operation.jl | 2 +- src/groups/special_linear.jl | 2 +- src/manifolds/CenteredMatrices.jl | 4 ++-- src/manifolds/CholeskySpace.jl | 4 ++-- src/manifolds/Circle.jl | 2 +- src/manifolds/Elliptope.jl | 2 +- src/manifolds/EmbeddedTorus.jl | 2 +- src/manifolds/FixedRankMatrices.jl | 2 +- src/manifolds/HyperbolicHyperboloid.jl | 2 +- src/manifolds/KendallsPreShapeSpace.jl | 4 ++-- src/manifolds/MultinomialDoublyStochastic.jl | 4 ++-- src/manifolds/ProbabilitySimplex.jl | 2 +- src/manifolds/ProjectiveSpace.jl | 2 +- src/manifolds/SPDFixedDeterminant.jl | 2 +- src/manifolds/Spectrahedron.jl | 2 +- src/manifolds/Sphere.jl | 2 +- src/manifolds/SphereSymmetricMatrices.jl | 4 ++-- src/manifolds/SymmetricPositiveSemidefiniteFixedRank.jl | 2 +- src/manifolds/Symplectic.jl | 4 ++-- src/manifolds/SymplecticStiefel.jl | 4 ++-- 20 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/groups/addition_operation.jl b/src/groups/addition_operation.jl index 0a104f506b..885974cf53 100644 --- a/src/groups/addition_operation.jl +++ b/src/groups/addition_operation.jl @@ -87,7 +87,7 @@ function is_identity( ::AdditionGroupTrait, G::AbstractDecoratorManifold, q::T; - atol=sqrt(prod(representation_size(G))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(G))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} return isapprox(G, q, zero(q); atol=atol, kwargs...) diff --git a/src/groups/special_linear.jl b/src/groups/special_linear.jl index c7665482fa..e8f8eb05a9 100644 --- a/src/groups/special_linear.jl +++ b/src/groups/special_linear.jl @@ -53,7 +53,7 @@ function check_vector( G::SpecialLinear, p, X::T; - atol=sqrt(prod(representation_size(G))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(G))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} trX = tr(inverse_translate_diff(G, p, p, X, LeftForwardAction())) diff --git a/src/manifolds/CenteredMatrices.jl b/src/manifolds/CenteredMatrices.jl index 6df08d01f4..e5f801797a 100644 --- a/src/manifolds/CenteredMatrices.jl +++ b/src/manifolds/CenteredMatrices.jl @@ -38,7 +38,7 @@ The tolerance for the column sums of `p` can be set using `kwargs...`. function check_point( M::CenteredMatrices, p::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} m, n = get_parameter(M.size) @@ -65,7 +65,7 @@ function check_vector( M::CenteredMatrices, p, X::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} m, n = get_parameter(M.size) diff --git a/src/manifolds/CholeskySpace.jl b/src/manifolds/CholeskySpace.jl index 33202e41da..2d2226c4b4 100644 --- a/src/manifolds/CholeskySpace.jl +++ b/src/manifolds/CholeskySpace.jl @@ -31,7 +31,7 @@ The tolerance for the tests can be set using the `kwargs...`. function check_point( M::CholeskySpace, p::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} cks = check_size(M, p) @@ -63,7 +63,7 @@ function check_vector( M::CholeskySpace, p, X; - atol=sqrt(prod(representation_size(M)) * eps(eltype(p))), + atol::Real=sqrt(prod(representation_size(M)) * eps(float(eltype(p)))), kwargs..., ) if !isapprox(norm(strictlyUpperTriangular(X)), 0.0; atol=atol, kwargs...) diff --git a/src/manifolds/Circle.jl b/src/manifolds/Circle.jl index 76799ec164..ba0c68d33f 100644 --- a/src/manifolds/Circle.jl +++ b/src/manifolds/Circle.jl @@ -82,7 +82,7 @@ function check_vector( M::Circle{ℂ}, p, X::T; - atol=sqrt(eps(real(float(number_eltype(T))))), + atol::Real=sqrt(eps(real(float(number_eltype(T))))), kwargs..., ) where {T} if !isapprox(abs(complex_dot(p, X)), 0; atol=atol, kwargs...) diff --git a/src/manifolds/Elliptope.jl b/src/manifolds/Elliptope.jl index 5bfc2e8fbc..e7d7d7432d 100644 --- a/src/manifolds/Elliptope.jl +++ b/src/manifolds/Elliptope.jl @@ -89,7 +89,7 @@ function check_vector( M::Elliptope, q, Y::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} X = q * Y' + Y * q' diff --git a/src/manifolds/EmbeddedTorus.jl b/src/manifolds/EmbeddedTorus.jl index 2b5eca05d6..9adb27d2d2 100644 --- a/src/manifolds/EmbeddedTorus.jl +++ b/src/manifolds/EmbeddedTorus.jl @@ -52,7 +52,7 @@ Check whether `X` is a valid vector tangent to `p` on the [`EmbeddedTorus`](@ref The method checks if the vector `X` is orthogonal to the vector normal to the torus, see [`normal_vector`](@ref). Absolute tolerance can be set using `atol`. """ -function check_vector(M::EmbeddedTorus, p, X; atol=eps(float(eltype(p))), kwargs...) +function check_vector(M::EmbeddedTorus, p, X; atol::Real=eps(float(eltype(p))), kwargs...) dot_nX = dot(normal_vector(M, p), X) if !isapprox(dot_nX, 0; atol=atol, kwargs...) return DomainError(dot_nX, "The vector $(X) is not tangent to $(p) from $(M).") diff --git a/src/manifolds/FixedRankMatrices.jl b/src/manifolds/FixedRankMatrices.jl index bbe676f7aa..ddc145ea82 100644 --- a/src/manifolds/FixedRankMatrices.jl +++ b/src/manifolds/FixedRankMatrices.jl @@ -328,7 +328,7 @@ function check_vector( M::FixedRankMatrices, p::SVDMPoint, X::UMVTVector; - atol=sqrt(prod(representation_size(M)) * eps(float(eltype(p.U)))), + atol::Real=sqrt(prod(representation_size(M)) * eps(float(eltype(p.U)))), kwargs..., ) m, n, k = get_parameter(M.size) diff --git a/src/manifolds/HyperbolicHyperboloid.jl b/src/manifolds/HyperbolicHyperboloid.jl index 2f77770b38..b5df6543bb 100644 --- a/src/manifolds/HyperbolicHyperboloid.jl +++ b/src/manifolds/HyperbolicHyperboloid.jl @@ -39,7 +39,7 @@ function check_vector( M::Hyperbolic, p, X::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} if !isapprox(minkowski_metric(p, X), 0; atol=atol, kwargs...) diff --git a/src/manifolds/KendallsPreShapeSpace.jl b/src/manifolds/KendallsPreShapeSpace.jl index 851ce42ed7..3b9ef08dc6 100644 --- a/src/manifolds/KendallsPreShapeSpace.jl +++ b/src/manifolds/KendallsPreShapeSpace.jl @@ -40,7 +40,7 @@ each row has zero mean. Other conditions are checked via embedding in [`ArraySph function check_point( M::KendallsPreShapeSpace, p; - atol=sqrt(eps(float(eltype(p)))), + atol::Real=sqrt(eps(float(eltype(p)))), kwargs..., ) for p_row in eachrow(p) @@ -64,7 +64,7 @@ function check_vector( M::KendallsPreShapeSpace, p, X; - atol=sqrt(eps(float(eltype(X)))), + atol::Real=sqrt(eps(float(eltype(X)))), kwargs..., ) for X_row in eachrow(X) diff --git a/src/manifolds/MultinomialDoublyStochastic.jl b/src/manifolds/MultinomialDoublyStochastic.jl index 7e896d1181..40a4ef3e03 100644 --- a/src/manifolds/MultinomialDoublyStochastic.jl +++ b/src/manifolds/MultinomialDoublyStochastic.jl @@ -63,7 +63,7 @@ i.e. is a matrix with positive entries whose rows and columns sum to one. function check_point( M::MultinomialDoubleStochastic, p::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} n = get_parameter(M.size)[1] @@ -87,7 +87,7 @@ function check_vector( M::MultinomialDoubleStochastic, p, X::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} r = sum(X, dims=2) # check for stochastic rows diff --git a/src/manifolds/ProbabilitySimplex.jl b/src/manifolds/ProbabilitySimplex.jl index 8c28d9ed71..953dff50b3 100644 --- a/src/manifolds/ProbabilitySimplex.jl +++ b/src/manifolds/ProbabilitySimplex.jl @@ -133,7 +133,7 @@ function check_vector( M::ProbabilitySimplex, p, X::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} if !isapprox(sum(X), 0.0; atol=atol, kwargs...) diff --git a/src/manifolds/ProjectiveSpace.jl b/src/manifolds/ProjectiveSpace.jl index a484f8ed10..a60b4d57f2 100644 --- a/src/manifolds/ProjectiveSpace.jl +++ b/src/manifolds/ProjectiveSpace.jl @@ -130,7 +130,7 @@ function check_vector( M::AbstractProjectiveSpace, p, X::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} if !isapprox(dot(p, X), 0; atol=atol, kwargs...) diff --git a/src/manifolds/SPDFixedDeterminant.jl b/src/manifolds/SPDFixedDeterminant.jl index bf7821afb3..d72d3f1f8d 100644 --- a/src/manifolds/SPDFixedDeterminant.jl +++ b/src/manifolds/SPDFixedDeterminant.jl @@ -86,7 +86,7 @@ function check_vector( M::SPDFixedDeterminant, p, X::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} if !isapprox(tr(X), 0; atol=atol, kwargs...) diff --git a/src/manifolds/Spectrahedron.jl b/src/manifolds/Spectrahedron.jl index 781832aceb..082b6f8fa0 100644 --- a/src/manifolds/Spectrahedron.jl +++ b/src/manifolds/Spectrahedron.jl @@ -89,7 +89,7 @@ function check_vector( M::Spectrahedron, q, Y::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} X = q * Y' + Y * q' diff --git a/src/manifolds/Sphere.jl b/src/manifolds/Sphere.jl index 5b34d88aac..17fd4edac8 100644 --- a/src/manifolds/Sphere.jl +++ b/src/manifolds/Sphere.jl @@ -134,7 +134,7 @@ function check_vector( M::AbstractSphere, p, X::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} if !isapprox(abs(real(dot(p, X))), 0; atol=atol, kwargs...) diff --git a/src/manifolds/SphereSymmetricMatrices.jl b/src/manifolds/SphereSymmetricMatrices.jl index c6452f5294..1c9eecf0f0 100644 --- a/src/manifolds/SphereSymmetricMatrices.jl +++ b/src/manifolds/SphereSymmetricMatrices.jl @@ -38,7 +38,7 @@ The tolerance for the symmetry of `p` can be set using `kwargs...`. function check_point( M::SphereSymmetricMatrices, p::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} if !isapprox(norm(p - p'), 0; atol=atol, kwargs...) @@ -63,7 +63,7 @@ function check_vector( M::SphereSymmetricMatrices, p, X::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} if !isapprox(norm(X - X'), 0; atol=atol, kwargs...) diff --git a/src/manifolds/SymmetricPositiveSemidefiniteFixedRank.jl b/src/manifolds/SymmetricPositiveSemidefiniteFixedRank.jl index 9e42ef09d1..65c774f07c 100644 --- a/src/manifolds/SymmetricPositiveSemidefiniteFixedRank.jl +++ b/src/manifolds/SymmetricPositiveSemidefiniteFixedRank.jl @@ -152,7 +152,7 @@ function _isapprox( M::SymmetricPositiveSemidefiniteFixedRank, p::T, q; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} return isapprox(norm(p - q), 0; atol=atol, kwargs...) || diff --git a/src/manifolds/Symplectic.jl b/src/manifolds/Symplectic.jl index eb26d02b77..67b3492b3f 100644 --- a/src/manifolds/Symplectic.jl +++ b/src/manifolds/Symplectic.jl @@ -215,7 +215,7 @@ The tolerance can be set with `kwargs...` (e.g. `atol = 1.0e-14`). function check_point( M::Symplectic, p::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} # Perform check that the matrix lives on the real symplectic manifold: @@ -254,7 +254,7 @@ function check_vector( M::Symplectic, p, X::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} Q = SymplecticMatrix(p, X) diff --git a/src/manifolds/SymplecticStiefel.jl b/src/manifolds/SymplecticStiefel.jl index a43c064e4b..7188e0dafe 100644 --- a/src/manifolds/SymplecticStiefel.jl +++ b/src/manifolds/SymplecticStiefel.jl @@ -106,7 +106,7 @@ The tolerance can be set with `kwargs...` (e.g. `atol = 1.0e-14`). function check_point( M::SymplecticStiefel, p::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {T} # Perform check that the matrix lives on the real symplectic manifold: @@ -151,7 +151,7 @@ function check_vector( M::SymplecticStiefel{S,𝔽}, p, X::T; - atol=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), + atol::Real=sqrt(prod(representation_size(M))) * eps(real(float(number_eltype(T)))), kwargs..., ) where {S,T,𝔽} n, k = get_parameter(M.size)