summaryrefslogtreecommitdiff
path: root/src/python/test/test_tomato.py
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2020-05-25 22:56:04 +0200
committerMarc Glisse <marc.glisse@inria.fr>2020-05-25 22:56:04 +0200
commit2fb0d594060958804239fcdad5336832ea5133d0 (patch)
treeb9da0c4a87417f9ab168d7d3c9b761d61650ea41 /src/python/test/test_tomato.py
parentcaa7c97d812acc3559aaecedc6e44e5f41d8a6af (diff)
Add test
Diffstat (limited to 'src/python/test/test_tomato.py')
-rwxr-xr-xsrc/python/test/test_tomato.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/python/test/test_tomato.py b/src/python/test/test_tomato.py
new file mode 100755
index 00000000..0a33b86e
--- /dev/null
+++ b/src/python/test/test_tomato.py
@@ -0,0 +1,27 @@
+""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ Author(s): Marc Glisse
+
+ Copyright (C) 2020 Inria
+
+ Modification(s):
+ - YYYY/MM Author: Description of the modification
+"""
+
+from gudhi.clustering.tomato import Tomato
+import numpy as np
+import pytest
+
+
+def test_tomato_something():
+ a = [(1, 2), (1.1, 1.9), (0.9, 1.8), (10, 0), (10.1, 0.05), (10.2, -0.1), (5.4, 0)]
+ t = Tomato(metric="euclidean", n_clusters=2, k=4, n_jobs=-1, eps=0.05)
+ assert np.array_equal(t.fit_predict(a), [1,1,1,0,0,0,0]) # or with swapped 0 and 1
+
+ t = Tomato(density_type='KDE', r=1, k=4)
+ t.fit(a)
+ assert np.array_equal(t.leaf_labels_, [1,1,1,0,0,0,0]) # or with swapped 0 and 1
+
+ t = Tomato(graph_type='radius', r=4.7, k=4)
+ t.fit(a)
+ assert t.max_weight_per_cc_.size == 2