[Scipy-svn] r4598 - trunk/scipy/cluster/tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Mon Aug 4 15:00:13 EDT 2008
Author: damian.eads
Date: 2008-08-04 14:00:04 -0500 (Mon, 04 Aug 2008)
New Revision: 4598
Modified:
trunk/scipy/cluster/tests/test_hierarchy.py
Log:
Moved distance tests out of test_hierarchy.py
Modified: trunk/scipy/cluster/tests/test_hierarchy.py
===================================================================
--- trunk/scipy/cluster/tests/test_hierarchy.py 2008-08-04 18:58:20 UTC (rev 4597)
+++ trunk/scipy/cluster/tests/test_hierarchy.py 2008-08-04 19:00:04 UTC (rev 4598)
@@ -38,7 +38,7 @@
import numpy
from numpy.testing import *
-from scipy.cluster.hierarchy import squareform, linkage, from_mlab_linkage, numobs_dm, numobs_y, numobs_linkage
+from scipy.cluster.hierarchy import squareform, linkage, from_mlab_linkage, numobs_dm, numobs_y, numobs_linkage, inconsistent
from scipy.cluster.distance import pdist, matching, jaccard, dice, sokalsneath, rogerstanimoto, russellrao, yule
_tdist = numpy.array([[0, 662, 877, 255, 412, 996],
@@ -58,9 +58,23 @@
"linkage-complete-tdist.txt",
"linkage-average-tdist.txt",
"linkage-weighted-tdist.txt",
+ "inconsistent-complete-tdist-depth-1.txt",
+ "inconsistent-complete-tdist-depth-2.txt",
+ "inconsistent-complete-tdist-depth-3.txt",
+ "inconsistent-complete-tdist-depth-4.txt",
+ "inconsistent-single-tdist-depth-0.txt",
+ "inconsistent-single-tdist-depth-1.txt",
+ "inconsistent-single-tdist-depth-2.txt",
+ "inconsistent-single-tdist-depth-3.txt",
+ "inconsistent-single-tdist-depth-4.txt",
+ "inconsistent-single-tdist-depth-5.txt",
+ "inconsistent-single-tdist.txt",
+ "inconsistent-weighted-tdist-depth-1.txt",
+ "inconsistent-weighted-tdist-depth-2.txt",
+ "inconsistent-weighted-tdist-depth-3.txt",
+ "inconsistent-weighted-tdist-depth-4.txt",
"random-bool-data.txt"]
-
def load_testing_files():
for fn in _filenames:
name = fn.replace(".txt", "").replace("-ml", "")
@@ -204,6 +218,21 @@
#print Z, expectedZ, numpy.abs(Z - expectedZ).max()
self.failUnless(within_tol(Z, expectedZ, eps))
+class TestInconsistent(TestCase):
+
+ def test_single_inconsistent_tdist(self):
+ for i in xrange(0, 100):
+ yield help_single_inconsistent_depth, i
+
+def help_single_inconsistent_depth(self, i):
+ Y = squareform(_tdist)
+ Z = linkage(Y, 'single')
+ R = inconsistent(Z, i)
+ Rright = eo['inconsistent-single-tdist-depth-' + str(i)]
+ eps = 1e-05
+ print numpy.abs(R - Rright).max()
+ self.failUnless(within_tol(R, Rright, eps))
+
def within_tol(a, b, tol):
return numpy.abs(a - b).max() < tol
More information about the Scipy-svn
mailing list