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

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


Author: damian.eads
Date: 2008-11-07 15:26:07 -0600 (Fri, 07 Nov 2008)
New Revision: 5017

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

Modified: trunk/scipy/cluster/tests/test_hierarchy.py
===================================================================
--- trunk/scipy/cluster/tests/test_hierarchy.py	2008-11-07 21:05:03 UTC (rev 5016)
+++ trunk/scipy/cluster/tests/test_hierarchy.py	2008-11-07 21:26:07 UTC (rev 5017)
@@ -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, fclusterdata, is_isomorphic
+from scipy.cluster.hierarchy import linkage, from_mlab_linkage, to_mlab_linkage, numobs_linkage, inconsistent, cophenet, from_mlab_linkage, fclusterdata, fcluster, is_isomorphic
 from scipy.spatial.distance import squareform, pdist, numobs_dm, numobs_y
 
 _tdist = np.array([[0,    662,  877,  255,  412,  996],
@@ -253,26 +253,53 @@
 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."
+        "Tests fclusterdata(X, criterion='maxclust', t=2) on a random 3-cluster data set."
         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 with a random data set consisting of three clusters."
+        "Tests fclusterdata(X, criterion='maxclust', t=3) on a random 3-cluster data set."
         expectedT = eo['fclusterdata-maxclusts-3']
         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."
+        "Tests fclusterdata(X, criterion='maxclust', t=4) on a random 3-cluster data set."
         expectedT = eo['fclusterdata-maxclusts-4']
         X = eo['fclusterdata-X']
         T = fclusterdata(X, criterion='maxclust', t=4)
         self.failUnless(is_isomorphic(T, expectedT))
 
+    def test_fcluster_maxclusts_2(self):
+        "Tests fcluster(Z, criterion='maxclust', t=2) on a random 3-cluster data set."
+        expectedT = eo['fclusterdata-maxclusts-2']
+        X = eo['fclusterdata-X']
+        Y = pdist(X)
+        Z = linkage(Y)
+        T = fcluster(Z, criterion='maxclust', t=2)
+        self.failUnless(is_isomorphic(T, expectedT))
+
+    def test_fcluster_maxclusts_3(self):
+        "Tests fcluster(Z, criterion='maxclust', t=3) on a random 3-cluster data set."
+        expectedT = eo['fclusterdata-maxclusts-3']
+        X = eo['fclusterdata-X']
+        Y = pdist(X)
+        Z = linkage(Y)
+        T = fcluster(Z, criterion='maxclust', t=3)
+        self.failUnless(is_isomorphic(T, expectedT))
+
+    def test_fcluster_maxclusts_4(self):
+        "Tests fcluster(Z, criterion='maxclust', t=4) on a random 3-cluster data set."
+        expectedT = eo['fclusterdata-maxclusts-4']
+        X = eo['fclusterdata-X']
+        Y = pdist(X)
+        Z = linkage(Y)
+        T = fcluster(Z, 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