diff --git a/examples/all_pairs.py b/examples/all_pairs.py index 86f81a8..605c937 100644 --- a/examples/all_pairs.py +++ b/examples/all_pairs.py @@ -38,9 +38,9 @@ } } """] - print all_pairs(catalogue) - print all_pairs(catalogue, parallel=True) - print all_pairs(catalogue, distance=distances.kolmogorov) + print(all_pairs(catalogue)) + print(all_pairs(catalogue, parallel=True)) + print(all_pairs(catalogue, distance=distances.kolmogorov)) # Example code for loading a pickle file of submissions diff --git a/examples/clustering.py b/examples/clustering.py index 44ae443..fef869f 100644 --- a/examples/clustering.py +++ b/examples/clustering.py @@ -17,10 +17,14 @@ from ripoff import all_pairs, distances from ripoff.clustering import cluster -import urllib2 import hcluster import pylab +try: + import urllib.request as liburl +except ImportError: + import urllib2 as liburl + # some famous German literature urls = [("http://www.gutenberg.org/files/21000/21000-0.txt", "Faust 1"), ("http://www.gutenberg.org/cache/epub/2230/pg2230.txt", "Faust 2"), @@ -40,8 +44,8 @@ for url, name in urls: headers = {'User-Agent': 'Mozilla/5.0'} - req = urllib2.Request(url, None, headers) - catalogue.append(urllib2.urlopen(req).read()) + req = liburl.Request(url, None, headers) + catalogue.append(liburl.urlopen(req).read()) # calc similarity matrix M = all_pairs(catalogue, diff --git a/ripoff/clustering.py b/ripoff/clustering.py index 61dcc4b..f9a629e 100644 --- a/ripoff/clustering.py +++ b/ripoff/clustering.py @@ -12,21 +12,19 @@ @author: moschlar ''' -try: - import cStringIO as StringIO -except ImportError: - import StringIO +from io import StringIO -import pylab import hcluster - def cluster(M, method='complete'): return hcluster.linkage(hcluster.squareform(M), method=method) def dendrogram(M, method='complete', title='complete linkage clustering', **kw): - s = StringIO.StringIO() + + import pylab + + s = StringIO() pylab.figure() if title: pylab.title(title) diff --git a/setup.py b/setup.py index 28d1896..9289395 100644 --- a/setup.py +++ b/setup.py @@ -29,5 +29,5 @@ "Topic :: Software Development :: Libraries", "License :: OSI Approved :: BSD License", ], - install_requires=['numpy', 'hcluster', 'matplotlib'], + install_requires=['numpy', 'dedupe-hcluster', 'matplotlib'], )