summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/python/gudhi/representations/vector_methods.py14
-rwxr-xr-xsrc/python/test/test_representations.py18
2 files changed, 25 insertions, 7 deletions
diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py
index cdcb1fde..d4449e7d 100644
--- a/src/python/gudhi/representations/vector_methods.py
+++ b/src/python/gudhi/representations/vector_methods.py
@@ -606,16 +606,16 @@ class Atol(BaseEstimator, TransformerMixin):
>>> c = np.array([[3, 2, -1], [1, 2, -1]])
>>> atol_vectoriser = Atol(quantiser=KMeans(n_clusters=2, random_state=202006))
>>> atol_vectoriser.fit(X=[a, b, c]).centers
- array([[ 2. , 0.66666667, 3.33333333],
- [ 2.6 , 2.8 , -0.4 ]])
+ >>> # array([[ 2. , 0.66666667, 3.33333333],
+ >>> # [ 2.6 , 2.8 , -0.4 ]])
>>> atol_vectoriser(a)
- array([1.18168665, 0.42375966])
+ >>> # array([1.18168665, 0.42375966])
>>> atol_vectoriser(c)
- array([0.02062512, 1.25157463])
+ >>> # array([0.02062512, 1.25157463])
>>> atol_vectoriser.transform(X=[a, b, c])
- array([[1.18168665, 0.42375966],
- [0.29861028, 1.06330156],
- [0.02062512, 1.25157463]])
+ >>> # array([[1.18168665, 0.42375966],
+ >>> # [0.29861028, 1.06330156],
+ >>> # [0.02062512, 1.25157463]])
"""
def __init__(self, quantiser, weighting_method="cloud", contrast="gaussian"):
"""
diff --git a/src/python/test/test_representations.py b/src/python/test/test_representations.py
index 43c914f3..1c8f8cdb 100755
--- a/src/python/test/test_representations.py
+++ b/src/python/test/test_representations.py
@@ -46,6 +46,24 @@ def test_multiple():
assert d1 == pytest.approx(d2, rel=0.02)
+# Test sorted values as points order can be inverted, and sorted test is not documentation-friendly
+def test_atol_doc():
+ 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]])
+
+ atol_vectoriser = Atol(quantiser=KMeans(n_clusters=2, random_state=202006))
+ assert np.sort(atol_vectoriser.fit(X=[a, b, c]).centers, axis=0) == \
+ pytest.approx(np.array([[2. , 0.66666667, -0.4], \
+ [2.6, 2.8 , 3.33333333]]))
+ assert np.sort(atol_vectoriser(a)) == pytest.approx(np.array([0.42375966, 1.18168665]))
+ assert np.sort(atol_vectoriser(c)) == pytest.approx(np.array([0.02062512, 1.25157463]))
+ assert np.sort(atol_vectoriser.transform(X=[a, b, c]), axis=0) == \
+ pytest.approx(np.array([[0.02062512, 0.42375966], \
+ [0.29861028, 1.06330156], \
+ [1.18168665, 1.25157463]]))
+
+
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]])