Skip to content

Commit

Permalink
Fix statistics tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Dec 23, 2023
1 parent 27b1bbb commit c7fc451
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Manifolds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,10 @@ export ×,
convert,
complex_dot,
decorated_manifold,
default_vector_transport_method,
default_approximation_method,
default_inverse_retraction_method,
default_retraction_method,
default_vector_transport_method,
det_local_metric,
differential_canonical_project,
differential_canonical_project!,
Expand Down
7 changes: 5 additions & 2 deletions src/manifolds/Euclidean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ function check_vector(M::Euclidean{N,𝔽}, p, X; kwargs...) where {N,𝔽}
end

default_approximation_method(::Euclidean, ::typeof(mean)) = EfficientEstimator()
default_approximation_method(::Euclidean, ::typeof(median), ::Number) = EfficientEstimator()
function default_approximation_method(::Euclidean, ::typeof(median), ::Type{<:Number})
return EfficientEstimator()
end

function default_approximation_method(::Euclidean, ::typeof(median), ::Array{T,0}) where {T}
return EfficientEstimator()

Check warning on line 123 in src/manifolds/Euclidean.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/Euclidean.jl#L122-L123

Added lines #L122 - L123 were not covered by tests
end
Expand Down Expand Up @@ -610,7 +613,7 @@ function Statistics.median(
end
function Statistics.median(
::Union{Euclidean{TypeParameter{Tuple{}}},Euclidean{Tuple{}}},
x::AbstractVector{<:Number},
x::AbstractVector,
w::AbstractWeights,
::EfficientEstimator;
kwargs...,
Expand Down
4 changes: 2 additions & 2 deletions test/statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function test_median(
y = isnothing(method) ? median(M, x; kwargs...) : median(M, x, method; kwargs...)
@test is_point(M, y; atol=10^-9)
if yexp !== nothing
@test isapprox(M, y, yexp; atol=10^-5)
@test isapprox(M, y, yexp; atol=5 * 10^-5)
end
end

Expand Down Expand Up @@ -797,7 +797,7 @@ end
x = [normalize(randn(rng, 3)) for _ in 1:10]
w = pweights([rand(rng) for _ in 1:length(x)])
m = normalize(median(Euclidean(3), x, w))
mg = median(S, x, w, ExtrinsicEstimation(EfficientEstimator()))
mg = median(S, x, w, ExtrinsicEstimation(CyclicProximalPointEstimation()))
@test isapprox(S, m, mg)
end

Expand Down

0 comments on commit c7fc451

Please sign in to comment.