Skip to content

Commit

Permalink
small improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran committed Oct 4, 2022
1 parent b8189b6 commit fa91bed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/manifolds/MetricManifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ _drop_embedding_type(t::EmptyTrait) = t

function active_traits(f, M::MetricManifold, args...)
at = active_traits(f, M.manifold, args...)
idm = is_default_metric(M.manifold, M.metric)
imf = is_metric_function(f)
idm = imf && is_default_metric(M.manifold, M.metric)
return merge_traits(
idm ? IsDefaultMetric(M.metric) : EmptyTrait(),
IsMetricManifold(),
# avoid forwarding to the embedding if the metric is not the default one
idm ? at : _drop_embedding_type(at),
is_metric_function(f) ? EmptyTrait() : IsExplicitDecorator(),
imf ? EmptyTrait() : IsExplicitDecorator(),
)
end
# remetricise instead of double-decorating
Expand Down
7 changes: 6 additions & 1 deletion test/metric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,11 @@ Manifolds.inner(::MetricManifold{ℝ,<:AbstractManifold{ℝ},Issue539Metric}, p,
M = Sphere(2)
p = [0.49567358314486515, 0.3740229181343087, -0.7838460025302334]
X = [-1.1552859627097727, 0.40665559717366767, -0.5365163797547751]
@test 3 norm(MetricManifold(M, Issue539Metric()), p, X)^2
MM = MetricManifold(M, Issue539Metric())
@test norm(MM, p, X)^2 3
@test Manifolds._drop_embedding_type(
ManifoldsBase.merge_traits(IsEmbeddedSubmanifold()),
) === ManifoldsBase.EmptyTrait()
@test get_embedding(MM) === get_embedding(M)
end
end

0 comments on commit fa91bed

Please sign in to comment.