Skip to content

Commit ab97c9c

Browse files
committed
Merge branch 'python3' into release-1.2.0
2 parents 6d8175b + dba7b09 commit ab97c9c

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

cluster/cluster.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1616
#
1717

18+
from __future__ import print_function
19+
1820

1921
class Cluster(object):
2022
"""
@@ -107,12 +109,12 @@ def display(self, depth=0):
107109
"""
108110
Pretty-prints this cluster. Useful for debuging
109111
"""
110-
print depth * " " + "[level %s]" % self.__level
112+
print(depth * " " + "[level %s]" % self.__level)
111113
for item in self.__items:
112114
if isinstance(item, Cluster):
113115
item.display(depth + 1)
114116
else:
115-
print depth * " " + "%s" % item
117+
print(depth * " " + "%s" % item)
116118

117119
def topology(self):
118120
"""

cluster/method/hierarchical.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ def cluster(self, matrix=None, level=None, sequence=None):
227227
for cell in row:
228228
# if we are not on the diagonal (which is always 0)
229229
# and if this cell represents a new minimum...
230+
cell_lt_mdist = cell < mindistance if mindistance else False
230231
if ((rowindex != cellindex) and
231-
(cell < mindistance or smallestpair is None)):
232+
(cell_lt_mdist or smallestpair is None)):
232233
smallestpair = (rowindex, cellindex)
233234
mindistance = cell
234235
cellindex += 1

cluster/method/kmeans.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def initialise_clusters(self, input_, clustercount):
163163
"""
164164
# initialise the clusters with empty lists
165165
self.__clusters = []
166-
for _ in xrange(clustercount):
166+
for _ in range(clustercount):
167167
self.__clusters.append([])
168168

169169
# distribute the items into the clusters

cluster/util.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1616
#
1717

18+
from __future__ import print_function
1819
import logging
1920

2021

@@ -78,7 +79,7 @@ def minkowski_distance(x, y, p=2):
7879
"""
7980
from math import pow
8081
assert len(y) == len(x)
81-
assert x >= 1
82+
assert len(x) >= 1
8283
sum = 0
8384
for i in range(len(x)):
8485
sum += abs(x[i] - y[i]) ** p
@@ -147,7 +148,7 @@ def printmatrix(data):
147148
format = " %%%is |" % maxlen
148149
format = "|" + format * colcount
149150
for row in data:
150-
print format % tuple(row)
151+
print(format % tuple(row))
151152

152153

153154
def magnitude(a):

test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ def testNumpyRandom(self):
234234
unittest.makeSuite(HClusterSmallListTestCase),
235235
unittest.makeSuite(HClusterStringTestCase),
236236
unittest.makeSuite(KCluster2DTestCase),
237-
unittest.makeSuite(KClusterSFBugs)),
237+
unittest.makeSuite(KClusterSFBugs),
238238
unittest.makeSuite(KClusterSmallListTestCase),
239239
unittest.makeSuite(NumpyTests),
240-
)
240+
))
241241

242242
unittest.TextTestRunner(verbosity=2).run(suite)

0 commit comments

Comments
 (0)