Skip to content
Permalink
Browse files

fixed Nits

  • Loading branch information...
Nicolas Guigui Nicolas Guigui
Nicolas Guigui authored and Nicolas Guigui committed Sep 5, 2019
1 parent 4e34b74 commit 3d5cb9e560683f358a7329cc308d43ddafcb2029
@@ -8,8 +8,8 @@

import geomstats.backend as gs

from geomstats.geometry.manifold import Manifold
from geomstats.geometry.landmarks_space import LandmarksSpace, L2Metric
from geomstats.geometry.manifold import Manifold
from geomstats.geometry.euclidean_space import EuclideanMetric
from geomstats.geometry.euclidean_space import EuclideanSpace
from geomstats.geometry.riemannian_metric import RiemannianMetric
@@ -1,6 +1,5 @@
"""
Manifold, i.e. a topological space that locally resembles
Euclidean space near each point.
Manifold for sets of landmarks who belong to any given manifold
"""

import math
@@ -51,7 +50,7 @@ def __init__(self, ambient_manifold):

def inner_product(self, tangent_vec_a, tangent_vec_b, base_landmarks):
"""
Inner product between two tangent vectors at a base set of landmarks.
Inner product between two tangent vectors at a base landmark set.
"""
assert tangent_vec_a.shape == tangent_vec_b.shape
assert tangent_vec_a.shape == base_landmarks.shape
@@ -83,7 +82,7 @@ def inner_product(self, tangent_vec_a, tangent_vec_b, base_landmarks):

def dist(self, landmarks_a, landmarks_b):
"""
Geodesic distance between two discretized landmarkss.
Geodesic distance between two landmark sets.
"""
assert landmarks_a.shape == landmarks_b.shape
landmarks_a = gs.to_ndarray(landmarks_a, to_ndim=3)
@@ -114,10 +113,10 @@ def exp(self, tangent_vec, base_landmarks):
tangent_vec = gs.to_ndarray(tangent_vec, to_ndim=3)
base_landmarks = gs.to_ndarray(base_landmarks, to_ndim=3)

n_landmarks_sets, n_landmarks_per_set, n_coords = base_landmarks.shape
n_landmark_sets, n_landmarks_per_set, n_coords = base_landmarks.shape
n_tangent_vecs = tangent_vec.shape[0]

new_dim = n_landmarks_sets * n_landmarks_per_set
new_dim = n_landmark_sets * n_landmarks_per_set
new_base_landmarks = gs.reshape(base_landmarks, (new_dim, n_coords))
new_tangent_vec = gs.reshape(tangent_vec, (new_dim, n_coords))

@@ -129,29 +128,30 @@ def exp(self, tangent_vec, base_landmarks):

def log(self, landmarks, base_landmarks):
"""
Riemannian logarithm of a set of landmarks wrt a base set of landmarks.
Riemannian logarithm of a set of landmarks wrt a base landmark set.
"""
assert landmarks.shape == base_landmarks.shape
landmarks = gs.to_ndarray(landmarks, to_ndim=3)
base_landmarks = gs.to_ndarray(base_landmarks, to_ndim=3)

n_landmarks_sets, n_landmarks_per_set, n_coords = landmarks.shape
n_landmark_sets, n_landmarks_per_set, n_coords = landmarks.shape

landmarks = gs.reshape(
landmarks, (n_landmarks_sets * n_landmarks_per_set, n_coords))
landmarks, (n_landmark_sets * n_landmarks_per_set, n_coords))
base_landmarks = gs.reshape(
base_landmarks, (n_landmarks_sets * n_landmarks_per_set, n_coords))
base_landmarks, (n_landmark_sets * n_landmarks_per_set, n_coords))
log = self.ambient_metric.log(landmarks, base_landmarks)
log = gs.reshape(log, (n_landmarks_sets, n_landmarks_per_set, n_coords))
log = gs.reshape(log, (n_landmark_sets, n_landmarks_per_set, n_coords))
log = gs.squeeze(log)

return log

def geodesic(self, initial_landmarks,
end_landmarks=None, initial_tangent_vec=None):
"""
Geodesic specified either by an initial point and an end point,
either by an initial point and an initial tangent vector.
Geodesic specified either by an initial landmark set and an end
landmark set,
either by an initial landmark set and an initial tangent vector.
"""
landmarks_ndim = 2
initial_landmarks = gs.to_ndarray(initial_landmarks,
@@ -1,13 +1,13 @@
"""
Unit tests for parameterized manifolds.
Unit tests for landmarks space.
"""

import geomstats.backend as gs
import geomstats.tests
import tests.helper as helper

from geomstats.geometry.landmarks_space import LandmarksSpace
from geomstats.geometry.hypersphere import Hypersphere
from geomstats.geometry.landmarks_space import LandmarksSpace


class TestLandmarksSpaceMethods(geomstats.tests.TestCase):

0 comments on commit 3d5cb9e

Please sign in to comment.
You can’t perform that action at this time.