@@ -80,17 +80,17 @@ def minkowski_distance(x, y, p=2):
8080 return pow (sum , 1.0 / float (p ))
8181
8282
83- def genmatrix (list , combinfunc , symmetric = False , diagonal = None ):
83+ def genmatrix (data , combinfunc , symmetric = False , diagonal = None ):
8484 """
85- Takes a list and generates a 2D-matrix using the supplied combination
86- function to calculate the values.
85+ Takes a list of data and generates a 2D-matrix using the supplied
86+ combination function to calculate the values.
8787
8888 PARAMETERS
89- list - the list of items
89+ data - the list of items
9090 combinfunc - the function that is used to calculate teh value in a
9191 cell. It has to cope with two arguments.
9292 symmetric - Whether it will be a symmetric matrix along the diagonal.
93- For example, it the list contains integers, and the
93+ For example, if the list contains integers, and the
9494 combination function is abs(x-y), then the matrix will
9595 be symmetric.
9696 Default: False
@@ -102,10 +102,10 @@ def genmatrix(list, combinfunc, symmetric=False, diagonal=None):
102102 """
103103 matrix = []
104104 row_index = 0
105- for item in list :
105+ for item in data :
106106 row = []
107107 col_index = 0
108- for item2 in list :
108+ for item2 in data :
109109 if diagonal is not None and col_index == row_index :
110110 # if this is a cell on the diagonal
111111 row .append (diagonal )
@@ -122,23 +122,24 @@ def genmatrix(list, combinfunc, symmetric=False, diagonal=None):
122122 return matrix
123123
124124
125- def printmatrix (list ):
125+ def printmatrix (data ):
126126 """
127- Prints out a 2-dimensional list cleanly. This is useful for debugging.
127+ Prints out a 2-dimensional list of data cleanly.
128+ This is useful for debugging.
128129
129130 PARAMETERS
130- list - the 2D-list to display
131+ data - the 2D-list to display
131132 """
132133 # determine maximum length
133134 maxlen = 0
134- colcount = len (list [0 ])
135- for col in list :
135+ colcount = len (data [0 ])
136+ for col in data :
136137 for cell in col :
137138 maxlen = max (len (str (cell )), maxlen )
138139 # print data
139140 format = " %%%is |" % maxlen
140141 format = "|" + format * colcount
141- for row in list :
142+ for row in data :
142143 print format % tuple (row )
143144
144145
@@ -160,9 +161,9 @@ def dotproduct(a, b):
160161 return out
161162
162163
163- def centroid (list , method = median ):
164+ def centroid (data , method = median ):
164165 "returns the central vector of a list of vectors"
165166 out = []
166- for i in range (len (list [0 ])):
167- out .append (method ([x [i ] for x in list ]))
168- return tuple (out )
167+ for i in range (len (data [0 ])):
168+ out .append (method ([x [i ] for x in data ]))
169+ return tuple (out )
0 commit comments