[Scipy-svn] r5087 - in trunk/scipy: cluster spatial spatial/tests

scipy-svn@scip... scipy-svn@scip...
Wed Nov 12 22:23:29 CST 2008


Author: damian.eads
Date: 2008-11-12 22:23:27 -0600 (Wed, 12 Nov 2008)
New Revision: 5087

Modified:
   trunk/scipy/cluster/hierarchy.py
   trunk/scipy/spatial/distance.py
   trunk/scipy/spatial/tests/test_distance.py
Log:
Renamed numobs_* to num_obs_* to be more consistent with Python naming standards.

Modified: trunk/scipy/cluster/hierarchy.py
===================================================================
--- trunk/scipy/cluster/hierarchy.py	2008-11-13 04:14:38 UTC (rev 5086)
+++ trunk/scipy/cluster/hierarchy.py	2008-11-13 04:23:27 UTC (rev 5087)
@@ -590,7 +590,7 @@
     s = y.shape
     if len(s) == 1:
         distance.is_valid_y(y, throw=True, name='y')
-        d = distance.numobs_y(y)
+        d = distance.num_obs_y(y)
         if method not in _cpy_non_euclid_methods.keys():
             raise ValueError("Valid methods when the raw observations are omitted are 'single', 'complete', 'weighted', and 'average'.")
         # Since the C code does not support striding using strides.
@@ -1268,7 +1268,7 @@
     distance.is_valid_y(Y, throw=True)
     Z = np.asarray(Z, order='c')
     Y = np.asarray(Y, order='c')
-    return distance.numobs_y(Y) == num_obs_linkage(Z)
+    return distance.num_obs_y(Y) == num_obs_linkage(Z)
 
 def fcluster(Z, t, criterion='inconsistent', depth=2, R=None, monocrit=None):
     """

Modified: trunk/scipy/spatial/distance.py
===================================================================
--- trunk/scipy/spatial/distance.py	2008-11-13 04:14:38 UTC (rev 5086)
+++ trunk/scipy/spatial/distance.py	2008-11-13 04:23:27 UTC (rev 5087)
@@ -1,5 +1,4 @@
 """
-
 Function Reference
 ------------------
 
@@ -30,9 +29,9 @@
 +------------------+-------------------------------------------------+
 |is_valid_y        | checks for a valid condensed distance matrix.   |
 +------------------+-------------------------------------------------+
-|numobs_dm         | # of observations in a distance matrix.         |
+|num_obs_dm        | # of observations in a distance matrix.         |
 +------------------+-------------------------------------------------+
-|numobs_y          | # of observations in a condensed distance       |
+|num_obs_y         | # of observations in a condensed distance       |
 |                  | matrix.                                         |
 +------------------+-------------------------------------------------+
 
@@ -1515,7 +1514,7 @@
         valid = False
     return valid
 
-def numobs_dm(d):
+def num_obs_dm(d):
     """
     Returns the number of original observations that correspond to a
     square, redudant distance matrix ``D``.
@@ -1531,7 +1530,7 @@
     is_valid_dm(d, tol=np.inf, throw=True, name='d')
     return d.shape[0]
 
-def numobs_y(Y):
+def num_obs_y(Y):
     """
     Returns the number of original observations that correspond to a
     condensed distance matrix ``Y``.

Modified: trunk/scipy/spatial/tests/test_distance.py
===================================================================
--- trunk/scipy/spatial/tests/test_distance.py	2008-11-13 04:14:38 UTC (rev 5086)
+++ trunk/scipy/spatial/tests/test_distance.py	2008-11-13 04:23:27 UTC (rev 5087)
@@ -40,7 +40,7 @@
 from numpy.testing import *
 from scipy.spatial.distance import squareform, pdist, cdist, matching, \
                                    jaccard, dice, sokalsneath, rogerstanimoto, \
-                                   russellrao, yule, numobs_y, numobs_dm, \
+                                   russellrao, yule, num_obs_y, num_obs_dm, \
                                    is_valid_dm, is_valid_y
 
 _filenames = ["iris.txt",
@@ -1433,37 +1433,37 @@
 
 class TestNumObsY(TestCase):
 
-    def test_numobs_y_multi_matrix(self):
-        "Tests numobs_y with observation matrices of multiple sizes."
+    def test_num_obs_y_multi_matrix(self):
+        "Tests num_obs_y with observation matrices of multiple sizes."
         for n in xrange(2, 10):
             X = np.random.rand(n, 4)
             Y = pdist(X)
             #print A.shape, Y.shape, Yr.shape
-            self.failUnless(numobs_y(Y) == n)
+            self.failUnless(num_obs_y(Y) == n)
 
-    def test_numobs_y_1(self):
-        "Tests numobs_y(y) on a condensed distance matrix over 1 observations. Expecting exception."
+    def test_num_obs_y_1(self):
+        "Tests num_obs_y(y) on a condensed distance matrix over 1 observations. Expecting exception."
         self.failUnlessRaises(ValueError, self.check_y, 1)
 
-    def test_numobs_y_2(self):
-        "Tests numobs_y(y) on a condensed distance matrix over 2 observations."
+    def test_num_obs_y_2(self):
+        "Tests num_obs_y(y) on a condensed distance matrix over 2 observations."
         self.failUnless(self.check_y(2))
 
-    def test_numobs_y_3(self):
-        "Tests numobs_y(y) on a condensed distance matrix over 3 observations."
+    def test_num_obs_y_3(self):
+        "Tests num_obs_y(y) on a condensed distance matrix over 3 observations."
         self.failUnless(self.check_y(3))
 
-    def test_numobs_y_4(self):
-        "Tests numobs_y(y) on a condensed distance matrix over 4 observations."
+    def test_num_obs_y_4(self):
+        "Tests num_obs_y(y) on a condensed distance matrix over 4 observations."
         self.failUnless(self.check_y(4))
 
-    def test_numobs_y_5_10(self):
-        "Tests numobs_y(y) on a condensed distance matrix between 5 and 15 observations."
+    def test_num_obs_y_5_10(self):
+        "Tests num_obs_y(y) on a condensed distance matrix between 5 and 15 observations."
         for i in xrange(5, 16):
             self.minit(i)
 
-    def test_numobs_y_2_100(self):
-        "Tests numobs_y(y) on 100 improper condensed distance matrices. Expecting exception."
+    def test_num_obs_y_2_100(self):
+        "Tests num_obs_y(y) on 100 improper condensed distance matrices. Expecting exception."
         a = set([])
         for n in xrange(2, 16):
             a.add(n*(n-1)/2)
@@ -1477,49 +1477,49 @@
 
     def bad_y(self, n):
         y = np.random.rand(n)
-        return numobs_y(y)
+        return num_obs_y(y)
 
     def check_y(self, n):
-        return numobs_y(self.make_y(n)) == n
+        return num_obs_y(self.make_y(n)) == n
 
     def make_y(self, n):
         return np.random.rand((n*(n-1)/2))
 
 class TestNumObsDM(TestCase):
 
-    ############## numobs_dm
-    def test_numobs_dm_multi_matrix(self):
-        "Tests numobs_dm with observation matrices of multiple sizes."
+    ############## num_obs_dm
+    def test_num_obs_dm_multi_matrix(self):
+        "Tests num_obs_dm with observation matrices of multiple sizes."
         for n in xrange(1, 10):
             X = np.random.rand(n, 4)
             Y = pdist(X)
             A = squareform(Y)
             if verbose >= 3:
                 print A.shape, Y.shape
-            self.failUnless(numobs_dm(A) == n)
+            self.failUnless(num_obs_dm(A) == n)
 
-    def test_numobs_dm_0(self):
-        "Tests numobs_dm(D) on a 0x0 distance matrix. Expecting exception."
+    def test_num_obs_dm_0(self):
+        "Tests num_obs_dm(D) on a 0x0 distance matrix. Expecting exception."
         self.failUnless(self.check_D(0))
 
-    def test_numobs_dm_1(self):
-        "Tests numobs_dm(D) on a 1x1 distance matrix."
+    def test_num_obs_dm_1(self):
+        "Tests num_obs_dm(D) on a 1x1 distance matrix."
         self.failUnless(self.check_D(1))
 
-    def test_numobs_dm_2(self):
-        "Tests numobs_dm(D) on a 2x2 distance matrix."
+    def test_num_obs_dm_2(self):
+        "Tests num_obs_dm(D) on a 2x2 distance matrix."
         self.failUnless(self.check_D(2))
 
-    def test_numobs_dm_3(self):
-        "Tests numobs_dm(D) on a 3x3 distance matrix."
+    def test_num_obs_dm_3(self):
+        "Tests num_obs_dm(D) on a 3x3 distance matrix."
         self.failUnless(self.check_D(2))
 
-    def test_numobs_dm_4(self):
-        "Tests numobs_dm(D) on a 4x4 distance matrix."
+    def test_num_obs_dm_4(self):
+        "Tests num_obs_dm(D) on a 4x4 distance matrix."
         self.failUnless(self.check_D(4))
 
     def check_D(self, n):
-        return numobs_dm(self.make_D(n)) == n
+        return num_obs_dm(self.make_D(n)) == n
 
     def make_D(self, n):
         return np.random.rand(n, n)



More information about the Scipy-svn mailing list