[Scipy-svn] r5011 - in trunk/scipy/cluster: . tests

scipy-svn@scip... scipy-svn@scip...
Fri Nov 7 14:45:06 CST 2008


Author: damian.eads
Date: 2008-11-07 14:45:02 -0600 (Fri, 07 Nov 2008)
New Revision: 5011

Added:
   trunk/scipy/cluster/tests/fclusterdata-X.txt
   trunk/scipy/cluster/tests/fclusterdata-maxclusts-3.txt
Modified:
   trunk/scipy/cluster/hierarchy.py
   trunk/scipy/cluster/tests/test_hierarchy.py
Log:
Added data files for new tests.

Modified: trunk/scipy/cluster/hierarchy.py
===================================================================
--- trunk/scipy/cluster/hierarchy.py	2008-11-07 20:03:12 UTC (rev 5010)
+++ trunk/scipy/cluster/hierarchy.py	2008-11-07 20:45:02 UTC (rev 5011)
@@ -1374,7 +1374,7 @@
     return T
 
 def fclusterdata(X, t, criterion='inconsistent', \
-                 distance='euclid', depth=2, method='single', R=None):
+                 metric='euclidean', depth=2, method='single', R=None):
     """
     T = fclusterdata(X, t)
 
@@ -1390,7 +1390,7 @@
       observation i belongs.
 
     T = fclusterdata(X, t, criterion='inconsistent', method='single',
-                    distance='euclid', depth=2, R=None)
+                    metric='euclid', depth=2, R=None)
 
       Clusters the original observations in the n by m data matrix X using
       the thresholding criterion, linkage method, and distance metric
@@ -1406,7 +1406,7 @@
         method:     the linkage method to use. See linkage for
                     descriptions.
 
-        distance:   the distance metric for calculating pairwise
+        metric:     the distance metric for calculating pairwise
                     distances. See distance.pdist for descriptions and
                     linkage to verify compatibility with the linkage
                     method.
@@ -1422,12 +1422,12 @@
 
     This function is similar to MATLAB(TM) clusterdata function.
     """
-    X = np.asarray(X, order='c')
+    X = np.asarray(X, order='c', dtype=np.double)
 
     if type(X) != np.ndarray or len(X.shape) != 2:
         raise TypeError('The observation matrix X must be an n by m numpy array.')
 
-    Y = distance.pdist(X, metric=distance)
+    Y = distance.pdist(X, metric=metric)
     Z = linkage(Y, method=method)
     if R is None:
         R = inconsistent(Z, d=depth)

Added: trunk/scipy/cluster/tests/fclusterdata-X.txt
===================================================================
--- trunk/scipy/cluster/tests/fclusterdata-X.txt	2008-11-07 20:03:12 UTC (rev 5010)
+++ trunk/scipy/cluster/tests/fclusterdata-X.txt	2008-11-07 20:45:02 UTC (rev 5011)
@@ -0,0 +1,30 @@
+   5.2656366e-01   3.1416019e-01   8.0065637e-02
+   7.5020518e-01   4.6029983e-01   8.9869646e-01
+   6.6546123e-01   6.9401142e-01   9.1046570e-01
+   9.6404759e-01   1.4308220e-03   7.3987422e-01
+   1.0815906e-01   5.5302879e-01   6.6380478e-02
+   9.3135913e-01   8.2542491e-01   9.5231544e-01
+   6.7808696e-01   3.4190397e-01   5.6148195e-01
+   9.8273094e-01   7.0460521e-01   8.7097863e-02
+   6.1469161e-01   4.6998923e-02   6.0240645e-01
+   5.8016126e-01   9.1735497e-01   5.8816385e-01
+   1.3824631e+00   1.9635816e+00   1.9443788e+00
+   2.1067586e+00   1.6714873e+00   1.3485448e+00
+   1.3988007e+00   1.6614205e+00   1.3222455e+00
+   1.7141046e+00   1.4917638e+00   1.4543217e+00
+   1.5410234e+00   1.8437495e+00   1.6465895e+00
+   2.0851248e+00   1.8452435e+00   2.1734085e+00
+   1.3074874e+00   1.5380165e+00   2.1600774e+00
+   1.4144770e+00   1.9932907e+00   1.9910742e+00
+   1.6194349e+00   1.4770328e+00   1.8978816e+00
+   1.5988060e+00   1.5498898e+00   1.5756335e+00
+   3.3724738e+00   2.6963531e+00   3.3998170e+00
+   3.1370512e+00   3.3652809e+00   3.0608907e+00
+   3.2941325e+00   3.1961950e+00   2.9070017e+00
+   2.6551051e+00   3.0678590e+00   2.9719854e+00
+   3.3094104e+00   2.5928397e+00   2.5771411e+00
+   2.5955722e+00   3.3347737e+00   3.0879319e+00
+   2.5820618e+00   3.4161567e+00   3.2644199e+00
+   2.7112700e+00   2.7703245e+00   2.6346650e+00
+   2.7961785e+00   3.2547372e+00   3.4180156e+00
+   2.6474175e+00   2.5453804e+00   3.2535411e+00

Added: trunk/scipy/cluster/tests/fclusterdata-maxclusts-3.txt
===================================================================
--- trunk/scipy/cluster/tests/fclusterdata-maxclusts-3.txt	2008-11-07 20:03:12 UTC (rev 5010)
+++ trunk/scipy/cluster/tests/fclusterdata-maxclusts-3.txt	2008-11-07 20:45:02 UTC (rev 5011)
@@ -0,0 +1,30 @@
+   1.0000000e+00
+   1.0000000e+00
+   1.0000000e+00
+   1.0000000e+00
+   1.0000000e+00
+   1.0000000e+00
+   1.0000000e+00
+   1.0000000e+00
+   1.0000000e+00
+   1.0000000e+00
+   2.0000000e+00
+   2.0000000e+00
+   2.0000000e+00
+   2.0000000e+00
+   2.0000000e+00
+   2.0000000e+00
+   2.0000000e+00
+   2.0000000e+00
+   2.0000000e+00
+   2.0000000e+00
+   3.0000000e+00
+   3.0000000e+00
+   3.0000000e+00
+   3.0000000e+00
+   3.0000000e+00
+   3.0000000e+00
+   3.0000000e+00
+   3.0000000e+00
+   3.0000000e+00
+   3.0000000e+00

Modified: trunk/scipy/cluster/tests/test_hierarchy.py
===================================================================
--- trunk/scipy/cluster/tests/test_hierarchy.py	2008-11-07 20:03:12 UTC (rev 5010)
+++ trunk/scipy/cluster/tests/test_hierarchy.py	2008-11-07 20:45:02 UTC (rev 5011)
@@ -54,6 +54,7 @@
 eo = {}
 
 _filenames = ["iris.txt",
+              "mlab-random.txt",
               "linkage-single-tdist.txt",
               "linkage-complete-tdist.txt",
               "linkage-average-tdist.txt",
@@ -246,7 +247,12 @@
         print expectedZM, ZM
         self.failUnless((expectedZM == ZM).all())
 
+class TestFcluster(TestCase):
 
+    def test_fcluster(self):
+        "Tests fclusterdata with 'maxclusts' criterion with maxclusts=3."
+
+
 def help_single_inconsistent_depth(self, i):
     Y = squareform(_tdist)
     Z = linkage(Y, 'single')



More information about the Scipy-svn mailing list