[Scipy-svn] r5016 - trunk/scipy/cluster/tests

scipy-svn@scip... scipy-svn@scip...
Fri Nov 7 15:05:05 CST 2008


Author: damian.eads
Date: 2008-11-07 15:05:03 -0600 (Fri, 07 Nov 2008)
New Revision: 5016

Modified:
   trunk/scipy/cluster/tests/test_hierarchy.py
Log:
Added more tests for fclusterdata.

Modified: trunk/scipy/cluster/tests/test_hierarchy.py
===================================================================
--- trunk/scipy/cluster/tests/test_hierarchy.py	2008-11-07 20:58:53 UTC (rev 5015)
+++ trunk/scipy/cluster/tests/test_hierarchy.py	2008-11-07 21:05:03 UTC (rev 5016)
@@ -38,7 +38,7 @@
 import numpy as np
 from numpy.testing import *
 
-from scipy.cluster.hierarchy import linkage, from_mlab_linkage, to_mlab_linkage, numobs_linkage, inconsistent, cophenet, from_mlab_linkage
+from scipy.cluster.hierarchy import linkage, from_mlab_linkage, to_mlab_linkage, numobs_linkage, inconsistent, cophenet, from_mlab_linkage, fclusterdata, is_isomorphic
 from scipy.spatial.distance import squareform, pdist, numobs_dm, numobs_y
 
 _tdist = np.array([[0,    662,  877,  255,  412,  996],
@@ -252,12 +252,27 @@
 
 class TestFcluster(TestCase):
 
+    def test_fclusterdata_maxclusts_2(self):
+        "Tests fclusterdata with 'maxclusts' criterion with maxclusts=2 with a random data set consisting of three clusters."
+        expectedT = eo['fclusterdata-maxclusts-2']
+        X = eo['fclusterdata-X']
+        T = fclusterdata(X, criterion='maxclust', t=2)
+        self.failUnless(is_isomorphic(T, expectedT))
+
     def test_fclusterdata_maxclusts_3(self):
-        "Tests fclusterdata with 'maxclusts' criterion with maxclusts=3."
+        "Tests fclusterdata with 'maxclusts' criterion with maxclusts=3 with a random data set consisting of three clusters."
         expectedT = eo['fclusterdata-maxclusts-3']
-        T = hi.fcluster(Z, criterion='maxclust', t=3)
-        self.failUnless((expectedT == T).all())
+        X = eo['fclusterdata-X']
+        T = fclusterdata(X, criterion='maxclust', t=3)
+        self.failUnless(is_isomorphic(T, expectedT))
 
+    def test_fclusterdata_maxclusts_4(self):
+        "Tests fclusterdata with 'maxclusts' criterion with maxclusts=4 with a random data set consisting of three clusters."
+        expectedT = eo['fclusterdata-maxclusts-4']
+        X = eo['fclusterdata-X']
+        T = fclusterdata(X, criterion='maxclust', t=4)
+        self.failUnless(is_isomorphic(T, expectedT))
+
 def help_single_inconsistent_depth(self, i):
     Y = squareform(_tdist)
     Z = linkage(Y, 'single')



More information about the Scipy-svn mailing list