diff options
author | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-08-18 10:55:42 +0200 |
---|---|---|
committer | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-08-18 10:55:42 +0200 |
commit | a1cd7e9ead030654a1fdb6cfd50408103c458529 (patch) | |
tree | 9786156bfb00d5b4f85dda2458b087d60d1bc1a8 /src/python/test | |
parent | 85eec1ba750d56b66e3739dc486c6205f49fb31e (diff) | |
parent | 4737aaeb36a4ff3b27d7bcbb374911197ed09e5a (diff) |
Merge master and resolve conflicts
Diffstat (limited to 'src/python/test')
-rwxr-xr-x | src/python/test/test_alpha_complex.py | 15 | ||||
-rwxr-xr-x | src/python/test/test_representations.py | 17 | ||||
-rwxr-xr-x | src/python/test/test_simplex_tree.py | 19 |
3 files changed, 48 insertions, 3 deletions
diff --git a/src/python/test/test_alpha_complex.py b/src/python/test/test_alpha_complex.py index a4ee260b..814f8289 100755 --- a/src/python/test/test_alpha_complex.py +++ b/src/python/test/test_alpha_complex.py @@ -198,8 +198,7 @@ def test_delaunay_complex(): _delaunay_complex(precision) def _3d_points_on_a_plane(precision, default_filtration_value): - alpha = gd.AlphaComplex(off_file=gd.__root_source_dir__ + '/data/points/alphacomplexdoc.off', - precision = precision) + alpha = gd.AlphaComplex(off_file='alphacomplexdoc.off', precision = precision) simplex_tree = alpha.create_simplex_tree(default_filtration_value = default_filtration_value) assert simplex_tree.dimension() == 2 @@ -207,6 +206,18 @@ def _3d_points_on_a_plane(precision, default_filtration_value): assert simplex_tree.num_simplices() == 25 def test_3d_points_on_a_plane(): + off_file = open("alphacomplexdoc.off", "w") + off_file.write("OFF \n" \ + "7 0 0 \n" \ + "1.0 1.0 0.0\n" \ + "7.0 0.0 0.0\n" \ + "4.0 6.0 0.0\n" \ + "9.0 6.0 0.0\n" \ + "0.0 14.0 0.0\n" \ + "2.0 19.0 0.0\n" \ + "9.0 17.0 0.0\n" ) + off_file.close() + for default_filtration_value in [True, False]: for precision in ['fast', 'safe', 'exact']: _3d_points_on_a_plane(precision, default_filtration_value) diff --git a/src/python/test/test_representations.py b/src/python/test/test_representations.py index 589cee00..e5c211a0 100755 --- a/src/python/test/test_representations.py +++ b/src/python/test/test_representations.py @@ -4,6 +4,8 @@ import matplotlib.pyplot as plt import numpy as np import pytest +from sklearn.cluster import KMeans + def test_representations_examples(): # Disable graphics for testing purposes @@ -15,6 +17,7 @@ def test_representations_examples(): return None +from gudhi.representations.vector_methods import Atol from gudhi.representations.metrics import * from gudhi.representations.kernel_methods import * @@ -41,3 +44,17 @@ def test_multiple(): d2 = WassersteinDistance(order=2, internal_p=2, n_jobs=4).fit(l2).transform(l1) print(d1.shape, d2.shape) assert d1 == pytest.approx(d2, rel=.02) + + +def test_dummy_atol(): + a = np.array([[1, 2, 4], [1, 4, 0], [1, 0, 4]]) + b = np.array([[4, 2, 0], [4, 4, 0], [4, 0, 2]]) + c = np.array([[3, 2, -1], [1, 2, -1]]) + + for weighting_method in ["cloud", "iidproba"]: + for contrast in ["gaussian", "laplacian", "indicator"]: + atol_vectoriser = Atol(quantiser=KMeans(n_clusters=1, random_state=202006), weighting_method=weighting_method, contrast=contrast) + atol_vectoriser.fit([a, b, c]) + atol_vectoriser(a) + atol_vectoriser.transform(X=[a, b, c]) + diff --git a/src/python/test/test_simplex_tree.py b/src/python/test/test_simplex_tree.py index 1ca84c10..6f1d01cc 100755 --- a/src/python/test/test_simplex_tree.py +++ b/src/python/test/test_simplex_tree.py @@ -341,6 +341,24 @@ def test_simplices_iterator(): print("filtration is: ", simplex[1]) assert st.filtration(simplex[0]) == simplex[1] +def test_collapse_edges(): + st = SimplexTree() + + assert st.insert([0, 1], filtration=1.0) == True + assert st.insert([1, 2], filtration=1.0) == True + assert st.insert([2, 3], filtration=1.0) == True + assert st.insert([0, 3], filtration=1.0) == True + assert st.insert([0, 2], filtration=2.0) == True + assert st.insert([1, 3], filtration=2.0) == True + + assert st.num_simplices() == 10 + + st.collapse_edges() + assert st.num_simplices() == 9 + assert st.find([1, 3]) == False + for simplex in st.get_skeleton(0): + assert simplex[1] == 1. + def test_reset_filtration(): st = SimplexTree() @@ -361,4 +379,3 @@ def test_reset_filtration(): assert st.filtration(simplex[0]) >= 1. else: assert st.filtration(simplex[0]) == 0. - |