Skip to content

Commit

Permalink
less verbose tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodmillman committed Jan 4, 2009
1 parent 242c8ce commit 5b88264
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
40 changes: 20 additions & 20 deletions scipy/cluster/tests/test_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_linkage_single_q(self):
Zmlab = eo['linkage-Q-single']
eps = 1e-06
expectedZ = from_mlab_linkage(Zmlab)
print abs(Z-expectedZ).max()
#print abs(Z-expectedZ).max()
self.failUnless(within_tol(Z, expectedZ, eps))

def test_linkage_complete_q(self):
Expand All @@ -162,7 +162,7 @@ def test_linkage_complete_q(self):
Zmlab = eo['linkage-Q-complete']
eps = 1e-07
expectedZ = from_mlab_linkage(Zmlab)
print abs(Z-expectedZ).max()
#print abs(Z-expectedZ).max()
self.failUnless(within_tol(Z, expectedZ, eps))

def test_linkage_centroid_q(self):
Expand All @@ -172,7 +172,7 @@ def test_linkage_centroid_q(self):
Zmlab = eo['linkage-Q-centroid']
eps = 1e-07
expectedZ = from_mlab_linkage(Zmlab)
print abs(Z-expectedZ).max()
#print abs(Z-expectedZ).max()
self.failUnless(within_tol(Z, expectedZ, eps))

def test_linkage_weighted_q(self):
Expand All @@ -182,7 +182,7 @@ def test_linkage_weighted_q(self):
Zmlab = eo['linkage-Q-weighted']
eps = 1e-07
expectedZ = from_mlab_linkage(Zmlab)
print abs(Z-expectedZ).max()
#print abs(Z-expectedZ).max()
self.failUnless(within_tol(Z, expectedZ, eps))

class TestInconsistent(TestCase):
Expand All @@ -194,7 +194,7 @@ def test_single_inconsistent_tdist_1(self):
R = inconsistent(Z, 1)
Rright = eo['inconsistent-single-tdist-depth-1']
eps = 1e-15
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

def test_single_inconsistent_tdist_2(self):
Expand All @@ -204,7 +204,7 @@ def test_single_inconsistent_tdist_2(self):
R = inconsistent(Z, 2)
Rright = eo['inconsistent-single-tdist-depth-2']
eps = 1e-05
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

def test_single_inconsistent_tdist_3(self):
Expand All @@ -214,7 +214,7 @@ def test_single_inconsistent_tdist_3(self):
R = inconsistent(Z, 3)
Rright = eo['inconsistent-single-tdist-depth-3']
eps = 1e-05
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

def test_single_inconsistent_tdist_4(self):
Expand All @@ -224,7 +224,7 @@ def test_single_inconsistent_tdist_4(self):
R = inconsistent(Z, 4)
Rright = eo['inconsistent-single-tdist-depth-4']
eps = 1e-05
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

# with complete linkage...
Expand All @@ -236,7 +236,7 @@ def test_complete_inconsistent_tdist_1(self):
R = inconsistent(Z, 1)
Rright = eo['inconsistent-complete-tdist-depth-1']
eps = 1e-15
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

def test_complete_inconsistent_tdist_2(self):
Expand All @@ -246,7 +246,7 @@ def test_complete_inconsistent_tdist_2(self):
R = inconsistent(Z, 2)
Rright = eo['inconsistent-complete-tdist-depth-2']
eps = 1e-05
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

def test_complete_inconsistent_tdist_3(self):
Expand All @@ -256,7 +256,7 @@ def test_complete_inconsistent_tdist_3(self):
R = inconsistent(Z, 3)
Rright = eo['inconsistent-complete-tdist-depth-3']
eps = 1e-05
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

def test_complete_inconsistent_tdist_4(self):
Expand All @@ -266,7 +266,7 @@ def test_complete_inconsistent_tdist_4(self):
R = inconsistent(Z, 4)
Rright = eo['inconsistent-complete-tdist-depth-4']
eps = 1e-05
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

# with single linkage and Q data set
Expand All @@ -278,7 +278,7 @@ def test_single_inconsistent_Q_1(self):
R = inconsistent(Z, 1)
Rright = eo['inconsistent-Q-single-1']
eps = 1e-06
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

def test_single_inconsistent_Q_2(self):
Expand All @@ -288,7 +288,7 @@ def test_single_inconsistent_Q_2(self):
R = inconsistent(Z, 2)
Rright = eo['inconsistent-Q-single-2']
eps = 1e-06
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

def test_single_inconsistent_Q_3(self):
Expand All @@ -298,7 +298,7 @@ def test_single_inconsistent_Q_3(self):
R = inconsistent(Z, 3)
Rright = eo['inconsistent-Q-single-3']
eps = 1e-05
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

def test_single_inconsistent_Q_4(self):
Expand All @@ -308,7 +308,7 @@ def test_single_inconsistent_Q_4(self):
R = inconsistent(Z, 4)
Rright = eo['inconsistent-Q-single-4']
eps = 1e-05
print np.abs(R - Rright).max()
#print np.abs(R - Rright).max()
self.failUnless(within_tol(R, Rright, eps))

class TestCopheneticDistance(TestCase):
Expand Down Expand Up @@ -357,7 +357,7 @@ def test_from_mlab_linkage_multiple_rows(self):
[ 6., 9., 295., 6.]],
dtype=np.double)
ZS = from_mlab_linkage(Z)
print expectedZS, ZS
#print expectedZS, ZS
self.failUnless((expectedZS == ZS).all())


Expand Down Expand Up @@ -387,7 +387,7 @@ def test_from_mlab_linkage_multiple_rows(self):
[ 6., 9., 295., 6.]],
dtype=np.double)
ZM = to_mlab_linkage(Z)
print expectedZM, ZM
#print expectedZM, ZM
self.failUnless((expectedZM == ZM).all())

class TestFcluster(TestCase):
Expand Down Expand Up @@ -450,7 +450,7 @@ def test_leaders_single(self):
T = fcluster(Z, criterion='maxclust', t=3)
Lright = (np.array([53, 55, 56]), np.array([2, 3, 1]))
L = leaders(Z, T)
print L, Lright, T
#print L, Lright, T
self.failUnless((L[0] == Lright[0]).all() and (L[1] == Lright[1]).all())

class TestIsIsomorphic(TestCase):
Expand Down Expand Up @@ -1397,7 +1397,7 @@ def calculate_maximum_inconsistencies(Z, R, k=3):
n = Z.shape[0] + 1
B = np.zeros((n-1,))
q = np.zeros((3,))
print R.shape
#print R.shape
for i in xrange(0, n - 1):
q[:] = 0.0
left = Z[i, 0]
Expand Down
20 changes: 10 additions & 10 deletions scipy/cluster/tests/vq_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ def python_vq(all_data,code_book):
t1 = time.time()
codes1,dist1 = vq.vq(all_data,code_book)
t2 = time.time()
print 'fast (double):', t2 - t1
print ' first codes:', codes1[:5]
print ' first dist:', dist1[:5]
print ' last codes:', codes1[-5:]
print ' last dist:', dist1[-5:]
#print 'fast (double):', t2 - t1
#print ' first codes:', codes1[:5]
#print ' first dist:', dist1[:5]
#print ' last codes:', codes1[-5:]
#print ' last dist:', dist1[-5:]
float_obs = all_data.astype(np.float32)
float_code = code_book.astype(np.float32)
t1 = time.time()
codes1,dist1 = vq.vq(float_obs,float_code)
t2 = time.time()
print 'fast (float):', t2 - t1
print ' first codes:', codes1[:5]
print ' first dist:', dist1[:5]
print ' last codes:', codes1[-5:]
print ' last dist:', dist1[-5:]
#print 'fast (float):', t2 - t1
#print ' first codes:', codes1[:5]
#print ' first dist:', dist1[:5]
#print ' last codes:', codes1[-5:]
#print ' last dist:', dist1[-5:]

return codes1,dist1

Expand Down

0 comments on commit 5b88264

Please sign in to comment.