Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projection to closed curves #1015

Closed
wants to merge 254 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
254 commits
Select commit Hold shift + click to select a range
81cda1f
Correct irrelevant function call.
ythanwerdas Jan 20, 2021
627b8e8
Geodesics between simple shapes
Florent-Michel Apr 14, 2021
5590928
add test, remove not working code
Florent-Michel Apr 15, 2021
0341b8d
Merge branch 'master' of https://github.com/geomstats/geomstats
Florent-Michel Apr 22, 2021
0ec82f0
Add cell data and analysis of cells
Florent-Michel Apr 22, 2021
a14a69d
Fix style
Florent-Michel Apr 22, 2021
07fd2d0
loop with enumerate
Florent-Michel Apr 22, 2021
d08e1b3
Merge branch 'master' of https://github.com/geomstats/geomstats
Florent-Michel Apr 24, 2021
e946d61
Merge branch 'master' of https://github.com/geomstats/geomstats
Florent-Michel Apr 28, 2021
2da8dae
first commit for lognormal sampler
SaitejaUtpala May 17, 2021
d716e99
checks for values in init in sampler
SaitejaUtpala May 17, 2021
010c73b
vectorize code heavily
SaitejaUtpala May 18, 2021
25ce84b
fixed some issues
SaitejaUtpala May 18, 2021
a243d64
corrected import statements
SaitejaUtpala May 18, 2021
f53985b
add sampling for Euclidean space
SaitejaUtpala May 18, 2021
870a218
fix off diag bug
SaitejaUtpala May 19, 2021
35dfef1
add references and Exception handling
SaitejaUtpala May 19, 2021
524f7b1
add ABC to base classes
nguigs May 18, 2021
384adef
introduce open set abstract class
nguigs May 18, 2021
f3a34b6
metric as property
nguigs May 18, 2021
69479e7
harmonize metric property + test_projection_and_belongs for embedded …
nguigs May 19, 2021
89691e3
total space identified with fiber bundle
nguigs May 19, 2021
c22044b
docstrings
nguigs May 19, 2021
f30f79b
adapt grassmannian, dirichlet, poincare_half_space and discrete curves
nguigs May 19, 2021
c66ea73
add diag indices to backend
SaitejaUtpala May 20, 2021
ee0be42
minor adjustments
SaitejaUtpala May 23, 2021
6b13143
discrete curves as manifold
nguigs May 26, 2021
ac6fb9a
deal with embedded manifolds
nguigs May 26, 2021
bd641be
address comments
nguigs May 26, 2021
5b37a2e
change import prod
nguigs May 26, 2021
4d51142
fix imports and tests
nguigs May 26, 2021
0885cfd
add matrix lie groups
nguigs May 27, 2021
f3f2a84
docstrings
nguigs May 27, 2021
48954ab
remove regularize method in hypersphere
nguigs May 27, 2021
111cac3
common interface to hyperbolic spaces
nguigs May 28, 2021
33dea2d
fix prod for other backends
nguigs May 28, 2021
c02fb88
make tests pass again
nguigs May 28, 2021
684cf0f
address DeepSource and rename embedded_manifold.py to base.py
nguigs May 28, 2021
84bd7b3
DeepSource 2
nguigs May 28, 2021
96ea067
DeepSource 3
nguigs May 28, 2021
fc6cfdb
Merge branch 'master' of https://github.com/geomstats/geomstats
Florent-Michel May 28, 2021
d4d1274
Merge branch 'master' of https://github.com/geomstats/geomstats
Florent-Michel May 28, 2021
4dea651
Add projection to closed curves
Florent-Michel May 29, 2021
474efac
delete empty notebook
Florent-Michel May 29, 2021
9a92c97
Fix style
Florent-Michel May 29, 2021
04a266c
add test projection and belongs for hyperboloid and product manifold
nguigs May 31, 2021
7ec3190
change manifold type + intiate test
SaitejaUtpala May 31, 2021
f35ed97
first commit for tests
SaitejaUtpala May 31, 2021
b9b8ab1
test CI
SaitejaUtpala May 31, 2021
949310c
fix in tests
SaitejaUtpala May 31, 2021
433f77d
fix regularisation
nguigs May 31, 2021
0f0d9af
Deepsource and tol
nguigs May 31, 2021
c148ee4
DeepSource 2
nguigs May 31, 2021
ee462ea
DeepSource 3
nguigs May 31, 2021
3d4ef82
fix-1
SaitejaUtpala May 31, 2021
a2ccc38
fix-2
SaitejaUtpala May 31, 2021
e4e12d0
add ABC to base classes
nguigs May 18, 2021
0996ea1
introduce open set abstract class
nguigs May 18, 2021
5998ef1
metric as property
nguigs May 18, 2021
ab282e0
harmonize metric property + test_projection_and_belongs for embedded …
nguigs May 19, 2021
6e5bbfc
total space identified with fiber bundle
nguigs May 19, 2021
4c936f2
docstrings
nguigs May 19, 2021
9bc8e92
adapt grassmannian, dirichlet, poincare_half_space and discrete curves
nguigs May 19, 2021
81a2fb3
discrete curves as manifold
nguigs May 26, 2021
0901d7d
deal with embedded manifolds
nguigs May 26, 2021
ce4d3db
address comments
nguigs May 26, 2021
9b9cb70
change import prod
nguigs May 26, 2021
4ce771b
fix imports and tests
nguigs May 26, 2021
38f8836
add matrix lie groups
nguigs May 27, 2021
0eee147
docstrings
nguigs May 27, 2021
52f4a65
remove regularize method in hypersphere
nguigs May 27, 2021
5a37122
common interface to hyperbolic spaces
nguigs May 28, 2021
d826e8e
fix prod for other backends
nguigs May 28, 2021
891c7be
make tests pass again
nguigs May 28, 2021
2fdd677
address DeepSource and rename embedded_manifold.py to base.py
nguigs May 28, 2021
66a7744
DeepSource 2
nguigs May 28, 2021
9eabd56
DeepSource 3
nguigs May 28, 2021
0d17a51
fix-3
SaitejaUtpala May 31, 2021
0ed2b66
fix return statement
SaitejaUtpala May 31, 2021
9b0078b
fix-4
SaitejaUtpala May 31, 2021
35ef4be
fix-5
SaitejaUtpala May 31, 2021
b28a7fd
fix normal
SaitejaUtpala May 31, 2021
d66d7fe
normal dist shape fix
SaitejaUtpala May 31, 2021
7d67057
add GL(n)+
nguigs May 31, 2021
c0fdf59
lint-fix
SaitejaUtpala May 31, 2021
6c5701e
Merge branch 'master' into nguigs-product
nguigs May 31, 2021
84a0164
fix rejection sampler
nguigs May 31, 2021
0f026d7
Update lognormal.py
SaitejaUtpala Jun 1, 2021
6feeb44
Update lognormal.py
SaitejaUtpala Jun 1, 2021
9297e8a
Update opt-requirements.txt
SaitejaUtpala Jun 1, 2021
3130d3d
Update opt-requirements.txt
SaitejaUtpala Jun 1, 2021
eca776a
Update random.py
SaitejaUtpala Jun 1, 2021
27272fc
Update lognormal.py
SaitejaUtpala Jun 1, 2021
b8fedb9
Update lognormal.py
SaitejaUtpala Jun 1, 2021
95b8221
Update lognormal.py
SaitejaUtpala Jun 1, 2021
31ec7b8
Update lognormal.py
SaitejaUtpala Jun 1, 2021
86e1049
test to_tangent for product manifolds in matrix point_type
nguigs Jun 1, 2021
2e1af73
linting
nguigs Jun 1, 2021
58527ee
Update lognormal.py
SaitejaUtpala Jun 1, 2021
f37803b
Update lognormal.py
SaitejaUtpala Jun 1, 2021
bd35745
make it work with tensorflow
SaitejaUtpala Jun 2, 2021
098527a
backend correction
SaitejaUtpala Jun 2, 2021
521e47b
make it work with tensorflow
SaitejaUtpala Jun 2, 2021
cc5b2c5
reshape fix
SaitejaUtpala Jun 2, 2021
d128c5c
reshape fix
SaitejaUtpala Jun 2, 2021
aaa3381
make it work with tensorflow
SaitejaUtpala Jun 2, 2021
2e9a9ac
address review
nguigs Jun 2, 2021
8fd17ae
Merge pull request #1016 from nguigs/nguigs-product
nguigs Jun 2, 2021
cb3acaf
add tests for backend
SaitejaUtpala Jun 2, 2021
402f3d0
Merge branch 'master' of https://github.com/geomstats/geomstats into …
SaitejaUtpala Jun 2, 2021
47f8089
doc string changes
SaitejaUtpala Jun 2, 2021
01a25ec
resolve merge conflict
SaitejaUtpala Jun 2, 2021
3a4587b
doc string
SaitejaUtpala Jun 2, 2021
9ee6768
trigger gh actions again
SaitejaUtpala Jun 2, 2021
4660e26
fix backend test
SaitejaUtpala Jun 2, 2021
08ce040
tf fix
SaitejaUtpala Jun 2, 2021
85fe0b9
tests-fix
SaitejaUtpala Jun 2, 2021
b558271
Update test_lognormal.py
SaitejaUtpala Jun 2, 2021
9cf7caf
Update test_lognormal.py
SaitejaUtpala Jun 2, 2021
c927c73
Update lognormal.py
SaitejaUtpala Jun 2, 2021
dd5b2d3
Update lognormal.py
SaitejaUtpala Jun 2, 2021
8d9a724
Update lognormal.py
SaitejaUtpala Jun 2, 2021
d84c564
Update test_backends.py
SaitejaUtpala Jun 2, 2021
46d6ffb
Update test_backends.py
SaitejaUtpala Jun 2, 2021
6b3dd52
Update test_backends.py
SaitejaUtpala Jun 2, 2021
c890fc4
Update __init__.py
SaitejaUtpala Jun 2, 2021
a283a39
Update test_backends.py
SaitejaUtpala Jun 2, 2021
fd181a8
Update test_lognormal.py
SaitejaUtpala Jun 2, 2021
be07724
Update __init__.py
SaitejaUtpala Jun 2, 2021
a103d79
Update __init__.py
SaitejaUtpala Jun 2, 2021
052c30a
Update __init__.py
SaitejaUtpala Jun 2, 2021
81e77d9
Update lognormal.py
SaitejaUtpala Jun 2, 2021
042e2e7
Update lognormal.py
SaitejaUtpala Jun 2, 2021
c2a2558
Update random.py
SaitejaUtpala Jun 2, 2021
d5b3f2b
Update test_backends.py
SaitejaUtpala Jun 2, 2021
1187b35
Update __init__.py
SaitejaUtpala Jun 2, 2021
4327d36
Update __init__.py
SaitejaUtpala Jun 2, 2021
4279a90
Update lognormal.py
SaitejaUtpala Jun 2, 2021
5ed7b52
Merge branch 'master' into full_rank_correlation_matrices
nguigs Jun 3, 2021
d55078c
update branch
nguigs Jun 3, 2021
28e0203
rewrite tangent_riemannian_submersion
nguigs Jun 3, 2021
4f0e79b
fix vertical projection
nguigs Jun 3, 2021
98fe2e3
make atts private
SaitejaUtpala Jun 4, 2021
85b4cca
expand documentation
SaitejaUtpala Jun 4, 2021
c119cd8
add more documentation
SaitejaUtpala Jun 4, 2021
c0f6369
linting
SaitejaUtpala Jun 4, 2021
8575ec8
linting in doc string
SaitejaUtpala Jun 4, 2021
4276bcd
Add versions for matplotlib
ninamiolane Jun 5, 2021
65e7a54
Change matplotlib version
ninamiolane Jun 5, 2021
004d419
first commit
SaitejaUtpala Jun 6, 2021
a9b524d
second commit
SaitejaUtpala Jun 6, 2021
d445599
remove inheritance from SymmetricMatrices in SPD
nguigs Jun 7, 2021
9d4aeab
Make align and log work
nguigs Jun 7, 2021
5315cf8
add all names in geometry.__init__
nguigs Jun 7, 2021
a197ba1
remove all names in geometry.__init__
nguigs Jun 7, 2021
d4cd2dc
add point to horizontal_lift
nguigs Jun 7, 2021
f3b30e8
address review
nguigs Jun 8, 2021
d4ec5e3
Merge pull request #902 from ythanwerdas/full_rank_correlation_matrices
nguigs Jun 8, 2021
7c763f2
addressing review comments
SaitejaUtpala Jun 8, 2021
a3d2f18
linint issues
SaitejaUtpala Jun 8, 2021
23226a3
linting again
SaitejaUtpala Jun 8, 2021
c854ec8
small correction in doc string
SaitejaUtpala Jun 8, 2021
0e62d69
Merge pull request #1008 from SaitejaUtpala/sampling
ninamiolane Jun 8, 2021
55d2e3e
Add isort and black as DeepSource transformers
ninamiolane Jun 8, 2021
2185b25
move dist_broadcast and gmm_pdf methods
nguigs Jun 10, 2021
aca1429
move weighted_gmm_pdf
nguigs Jun 10, 2021
f9532f5
DeepSource
nguigs Jun 10, 2021
1dc8808
move other methods
nguigs Jun 10, 2021
9c5ab36
add normalisation factor
nguigs Jun 14, 2021
a8cd696
Merge branch 'master' into update-pytorch-version
SaitejaUtpala Jun 15, 2021
37d2c58
change erf for stability
nguigs Jun 16, 2021
043e878
pass n_jobs to metric
nguigs Jun 16, 2021
0131b49
pass n_jobs to metric
nguigs Jun 16, 2021
67d8b63
Merge pull request #1030 from nguigs/nguigs-n_jobs
nguigs Jun 17, 2021
bf7d68e
Merge branch 'master' of github.com:nguigs/geomstats
nguigs Jun 17, 2021
fb1b407
Add parallel transport on the grassmann manifold
nguigs Jun 17, 2021
5ff1b54
docstring
nguigs Jun 17, 2021
2e53531
debug ball estimator of frechet mean
nguigs Jun 18, 2021
ed9e02f
linting
nguigs Jun 18, 2021
471a705
Merge pull request #1032 from nguigs/nguigs-grassmann-pt
nguigs Jun 19, 2021
e7cdd94
reformat and generalise ball estimator of frechet mean
nguigs Jun 20, 2021
67d9395
Merge branch 'update-pytorch-version' of https://github.com/SaitejaUt…
SaitejaUtpala Jun 20, 2021
1a1057f
add comb to backend because not available before python 3.8
nguigs Jun 20, 2021
088533a
Merge branch 'master' of https://github.com/geomstats/geomstats into …
SaitejaUtpala Jun 20, 2021
fe08023
minor adjustments
SaitejaUtpala Jun 20, 2021
ce1b4d5
add allclose from torch
SaitejaUtpala Jun 20, 2021
2d17ebb
cleaning-1
SaitejaUtpala Jun 20, 2021
c4c68e6
cleaning-2
SaitejaUtpala Jun 20, 2021
9ebc6ab
cleaning-3
SaitejaUtpala Jun 20, 2021
ed9bf65
cleaning-4
SaitejaUtpala Jun 20, 2021
fd2b72e
simplify
SaitejaUtpala Jun 20, 2021
11f8ba2
precision error
SaitejaUtpala Jun 20, 2021
bcca7d8
triu_indices
SaitejaUtpala Jun 20, 2021
2e7c993
remove redefinition
SaitejaUtpala Jun 20, 2021
5689d0a
minor adjust
SaitejaUtpala Jun 20, 2021
763eec6
revert to arcchosg
SaitejaUtpala Jun 20, 2021
c21550c
better error handling for pytorch
SaitejaUtpala Jun 20, 2021
69580e4
just trying with torch 1.9.0
SaitejaUtpala Jun 20, 2021
1b95d51
revert
SaitejaUtpala Jun 20, 2021
766bce4
revert
SaitejaUtpala Jun 20, 2021
551d23a
test error again
SaitejaUtpala Jun 20, 2021
45f03d6
fix typo
SaitejaUtpala Jun 20, 2021
308d689
debugging
SaitejaUtpala Jun 20, 2021
c2fb994
debugging
SaitejaUtpala Jun 20, 2021
6280203
debugging
SaitejaUtpala Jun 20, 2021
5e938e7
testing with verbose option
SaitejaUtpala Jun 21, 2021
5b71151
change tolerance and check
SaitejaUtpala Jun 21, 2021
37ed222
and&or
SaitejaUtpala Jun 21, 2021
98e792d
add and back
SaitejaUtpala Jun 21, 2021
880f3b1
add concatenate back
SaitejaUtpala Jun 21, 2021
80b6f1f
iterate
SaitejaUtpala Jun 21, 2021
f1cf6d6
typo
SaitejaUtpala Jun 21, 2021
029755e
add diagonal
SaitejaUtpala Jun 21, 2021
e082178
trig funcs
SaitejaUtpala Jun 21, 2021
79b0ecb
modify trig functions
SaitejaUtpala Jun 21, 2021
3f4dd73
cleaning
SaitejaUtpala Jun 21, 2021
764ea52
better error messages for torch
SaitejaUtpala Jun 21, 2021
972c71f
verbose-22
SaitejaUtpala Jun 21, 2021
95a9f85
boolean tensor
SaitejaUtpala Jun 21, 2021
c4147a1
formatting
SaitejaUtpala Jun 21, 2021
7580541
generalise batch gradient descent of frechet mean
nguigs Jun 22, 2021
04c4868
Merge branch 'nguigs-frachet-ball' into nguigs-em
nguigs Jun 22, 2021
c8951d9
adapt notebook
nguigs Jun 22, 2021
803621b
Merge pull request #1026 from nguigs/nguigs-em
nguigs Jun 22, 2021
e2c3678
improve vectors' visualisation on the disk and other small textual ch…
elodiemaignant Jun 22, 2021
a565168
clear tol printing
elodiemaignant Jun 22, 2021
22d21ae
FIX: README badge for build
ninamiolane Jun 26, 2021
ca06861
Merge branch 'master' into update-pytorch-version
SaitejaUtpala Jun 30, 2021
db6b651
merge
SaitejaUtpala Jun 30, 2021
00e1ee9
merge commit
SaitejaUtpala Jun 30, 2021
3432cfc
inc tol
SaitejaUtpala Jun 30, 2021
43b5b96
linting
SaitejaUtpala Jun 30, 2021
3baf69f
change random seed
SaitejaUtpala Jun 30, 2021
be273c6
increase tol
SaitejaUtpala Jun 30, 2021
c0e4fdd
import order inopt-req.txt
SaitejaUtpala Jun 30, 2021
5a71b19
Merge pull request #1027 from SaitejaUtpala/update-pytorch-version
ninamiolane Jul 6, 2021
609caea
Geodesics between simple shapes
Florent-Michel Apr 14, 2021
728e4cd
add test, remove not working code
Florent-Michel Apr 15, 2021
0cafe4d
Add cell data and analysis of cells
Florent-Michel Apr 22, 2021
1ec48c8
Fix style
Florent-Michel Apr 22, 2021
77f241d
loop with enumerate
Florent-Michel Apr 22, 2021
c79bff5
Add projection to closed curves
Florent-Michel May 29, 2021
99a79a7
delete empty notebook
Florent-Michel May 29, 2021
165f864
Fix style
Florent-Michel May 29, 2021
32f40b4
Clean code and add unit tests
Florent-Michel Jul 8, 2021
36be614
Merge branch 'discrete_curves' of https://github.com/Florent-Michel/g…
Florent-Michel Jul 8, 2021
a3651c4
Resolve conflicts
Florent-Michel Jul 8, 2021
ffde013
Resolve forgotten conflicts
Florent-Michel Jul 8, 2021
d54e853
Add abstract methods
Florent-Michel Jul 8, 2021
39e33a9
Fix attempt
Florent-Michel Jul 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"
runtime_version = "3.x.x"

[[transformers]]
name = "isort"
enabled = true

[[transformers]]
name = "black"
enabled = true
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ This work is supported by:
:target: https://twitter.com/geomstats
.. |PyPI version| image:: https://badge.fury.io/py/geomstats.svg
:target: https://badge.fury.io/py/geomstats
.. |Build Status| image:: https://travis-ci.org/geomstats/geomstats.svg?branch=master
:target: https://travis-ci.org/geomstats/geomstats
.. |Build Status| image:: https://github.com/geomstats/geomstats/actions/workflows/build.yml/badge.svg
:target: https://github.com/geomstats/geomstats/actions/workflows/build.yml
.. |Slack| image:: https://img.shields.io/badge/Slack-Join-yellow
:target: https://geomstats.slack.com/
.. |Coverage Status np| image:: https://codecov.io/gh/geomstats/geomstats/branch/master/graph/badge.svg?flag=numpy
Expand Down
5 changes: 2 additions & 3 deletions examples/learning_graph_embedding_and_predicting.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ def main():
kmeans = RiemannianKMeans(
metric=hyperbolic_embedding.manifold.metric,
n_clusters=n_clusters,
init='random',
mean_method='frechet-poincare-ball')
init='random')

centroids = kmeans.fit(X=embeddings, max_iter=100)
centroids = kmeans.fit(X=embeddings)
labels = kmeans.predict(X=embeddings)

colors = ['g', 'c', 'm']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

import geomstats.backend as gs
from geomstats.geometry.poincare_ball import PoincareBall
from geomstats.learning.expectation_maximization import RiemannianEM
from geomstats.learning.expectation_maximization import RiemannianEM, \
weighted_gmm_pdf

DEFAULT_PLOT_PRECISION = 100

Expand All @@ -41,13 +42,12 @@ def plot_gaussian_mixture_distribution(data,
gs.expand_dims(y_axis_samples[z_index], -1)),
axis=-1)

mesh_probabilities = PoincareBall.\
weighted_gmm_pdf(
mixture_coefficients,
x_y_plane_mesh,
means,
variances,
metric)
mesh_probabilities = weighted_gmm_pdf(
mixture_coefficients,
x_y_plane_mesh,
means,
variances,
metric)

z_axis_samples[z_index] = mesh_probabilities.sum(-1)

Expand Down Expand Up @@ -122,12 +122,9 @@ def expectation_maximisation_poincare_ball():

EM = RiemannianEM(n_gaussians=n_clusters,
metric=metric,
initialisation_method='random',
mean_method='frechet-poincare-ball')
initialisation_method='random')

means, variances, mixture_coefficients = EM.fit(
data=data,
max_iter=100)
means, variances, mixture_coefficients = EM.fit(data=data)

# Plot result
plot = plot_gaussian_mixture_distribution(data,
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_geodesics_poincare_polydisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def main():
vector = gs.array([3.5, 0.6, 0.8])
stack_vector = gs.stack([vector] * N_DISKS, axis=0)
vector = gs.to_ndarray(stack_vector, to_ndim=3)
initial_tangent_vec = POINCARE_POLYDISK.projection_to_tangent_space(
initial_tangent_vec = POINCARE_POLYDISK.to_tangent(
vector=vector, base_point=initial_point)
fig = plt.figure()
plot_geodesic_between_two_points(
Expand Down
11 changes: 4 additions & 7 deletions examples/plot_kmeans_manifolds.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ def kmean_poincare_ball():

kmeans = RiemannianKMeans(metric=metric,
n_clusters=n_clusters,
init='random',
mean_method='frechet-poincare-ball'
)
init='random')

centroids = kmeans.fit(X=data, max_iter=100)
centroids = kmeans.fit(X=data)
labels = kmeans.predict(X=data)

plt.figure(1)
Expand Down Expand Up @@ -86,8 +84,7 @@ def kmean_hypersphere():

# Generate data on south pole
cluster_2 = manifold.random_von_mises_fisher(kappa=50, n_samples=n_samples)
for point in cluster_2:
point[2] = -point[2]
cluster_2 = - cluster_2

data = gs.concatenate((cluster_1, cluster_2), axis=0)

Expand Down Expand Up @@ -122,7 +119,7 @@ def kmean_hypersphere():
s=200,
color='green')

ax.set_title('Kmeans on Hypersphere Manifold')
ax.set_title('Kmeans on the sphere')

return plt

Expand Down
2 changes: 1 addition & 1 deletion examples/plot_square_h2_klein_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
H2 = Hyperboloid(dim=2)
METRIC = H2.metric

SQUARE_SIZE = 20
SQUARE_SIZE = 10


def main():
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_square_h2_poincare_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
H2 = Hyperboloid(dim=2)
METRIC = H2.metric

SQUARE_SIZE = 20
SQUARE_SIZE = 10


def main():
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_square_h2_poincare_half_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
H2 = Hyperboloid(dim=2)
METRIC = H2.metric

SQUARE_SIZE = 20
SQUARE_SIZE = 10


def main():
Expand Down
6 changes: 6 additions & 0 deletions geomstats/_backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@
'clip',
'concatenate',
'convert_to_wider_dtype',
'comb',
'copy',
'cos',
'cosh',
'cross',
'cumprod',
'cumsum',
'diag_indices',
'diagonal',
'divide',
'dot',
Expand All @@ -63,6 +65,7 @@
'greater',
'hsplit',
'hstack',
'imag',
'isclose',
'isnan',
'less',
Expand All @@ -71,6 +74,7 @@
'log',
'logical_and',
'logical_or',
'mat_from_diag_triu_tril',
'matmul',
'maximum',
'mean',
Expand All @@ -83,6 +87,8 @@
'outer',
'polygamma',
'power',
'prod',
'real',
'repeat',
'reshape',
'rtol',
Expand Down
57 changes: 42 additions & 15 deletions geomstats/_backend/numpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Numpy based computation backend."""

import math

import autograd # NOQA
import autograd.numpy as np
from autograd.numpy import ( # NOQA
Expand Down Expand Up @@ -28,10 +30,11 @@
cross,
cumprod,
cumsum,
diag_indices,
diagonal,
divide,
dot,
dtype,
dtype as ndtype,
einsum,
empty,
empty_like,
Expand All @@ -48,6 +51,7 @@
hstack,
int32,
int64,
imag,
isclose,
isnan,
less,
Expand All @@ -65,6 +69,8 @@
ones_like,
outer,
power,
prod,
real,
repeat,
reshape,
shape,
Expand Down Expand Up @@ -92,7 +98,7 @@
zeros,
zeros_like
)
from autograd.scipy.special import polygamma # NOQA
from autograd.scipy.special import erf, polygamma # NOQA
from scipy.sparse import coo_matrix

from . import linalg # NOQA
Expand All @@ -101,16 +107,20 @@
from ..constants import np_atol, np_rtol

DTYPES = {
dtype('int32'): 0,
dtype('int64'): 1,
dtype('float32'): 2,
dtype('float64'): 3}
ndtype('int32'): 0,
ndtype('int64'): 1,
ndtype('float32'): 2,
ndtype('float64'): 3}


atol = np_atol
rtol = np_rtol


def comb(n, k):
return math.factorial(n) // math.factorial(k) // math.factorial(n - k)


def to_numpy(x):
return x

Expand Down Expand Up @@ -366,16 +376,33 @@ def array_from_sparse(indices, data, target_shape):
coo_matrix((data, list(zip(*indices))), target_shape).todense())


def erf(x):
cst_erf = 8.0 / (3.0 * np.pi) * (np.pi - 3.0) / (4.0 - np.pi)
return \
np.sign(x) * \
np.sqrt(1 - np.exp(-x * x *
(4 / np.pi + cst_erf * x * x) /
(1 + cst_erf * x * x)))


def triu_to_vec(x, k=0):
n = x.shape[-1]
rows, cols = triu_indices(n, k=k)
return x[..., rows, cols]


def mat_from_diag_triu_tril(diag, tri_upp, tri_low):
"""Build matrix from given components.

Forms a matrix from diagonal, strictly upper triangular and
strictly lower traingular parts.

Parameters
----------
diag : array_like, shape=[..., n]
tri_upp : array_like, shape=[..., (n * (n - 1)) / 2]
tri_low : array_like, shape=[..., (n * (n - 1)) / 2]

Returns
-------
mat : array_like, shape=[..., n, n]
"""
n = diag.shape[-1]
i, = np.diag_indices(n, ndim=1)
j, k = np.triu_indices(n, k=1)
mat = np.zeros(diag.shape + (n, ))
mat[..., i, i] = diag
mat[..., j, k] = tri_upp
mat[..., k, j] = tri_low
return mat