Remove useless variables
authorSimon Chabot <simon.chabot@logilab.fr>
Tue, 20 Nov 2012 15:13:29 +0100
changeset 156 0d248e74b20b
parent 155 90412c2a4d9e
child 157 30b9271eb762
Remove useless variables
aligner.py
demo.py
--- a/aligner.py	Tue Nov 20 15:07:41 2012 +0100
+++ b/aligner.py	Tue Nov 20 15:13:29 2012 +0100
@@ -252,7 +252,7 @@
     for alignind, targetind in findneighbours(ralignset, rtargetset, indexes, mode,
                                               neighbours_threshold, n_clusters,
                                               kwordsgram, siglen):
-        mat, matched = subalign(alignset, targetset, alignind, targetind,
+        _, matched = subalign(alignset, targetset, alignind, targetind,
                                 threshold, treatments)
         for k, values in matched.iteritems():
             subdict = global_matched.setdefault(k, set())
@@ -277,9 +277,9 @@
 
     if not uniq:
         for alignid in matched:
-            for targetid, dist in matched[alignid]:
+            for targetid, _ in matched[alignid]:
                 yield alignset[alignid][0], targetset[targetid][0]
     else:
         for alignid in matched:
-            bestid, dist = sorted(matched[alignid], key=lambda x:x[1])[0]
+            bestid, _ = sorted(matched[alignid], key=lambda x:x[1])[0]
             yield alignset[alignid][0], targetset[bestid][0]
--- a/demo.py	Tue Nov 20 15:07:41 2012 +0100
+++ b/demo.py	Tue Nov 20 15:13:29 2012 +0100
@@ -57,8 +57,8 @@
     treatments = {1: tr_name}
 
     print "Alignment started"
-    dmatrix, hasmatched = align(alignset, targetset, 0.4, treatments,
-                                dpath('demo0_results'))
+    align(alignset, targetset, 0.4, treatments,
+          dpath('demo0_results'))
 
     print "Done, see the resuls in %s" % dpath('demo0_results')
 
@@ -95,15 +95,15 @@
     treatments = {1: tr_name, 2: tr_geo}
 
     print "Alignment started"
-    dmatrix, hasmatched = align(alignset,           # The dataset to align
-                                targetset,          # The target dataset
-                                0.4,                # The maximal distance
-                                                    #   threshold
-                                treatments,         # The list of treatments to
-                                                    #   apply.
-                                dpath('demo1_results'))
-                                                    # Filename of the output
-                                                    #   result file
+    align(alignset,           # The dataset to align
+          targetset,          # The target dataset
+          0.4,                # The maximal distance
+                              #   threshold
+          treatments,         # The list of treatments to
+                              #   apply.
+          dpath('demo1_results'))
+                              # Filename of the output
+                              #   result file
     # the ``align()`` function return two items
     # 0. the computed distance matrix
     # 1. a boolean, True if at least one alignment has been done, False
@@ -139,7 +139,7 @@
                                mode='minibatch')
 
     # Let's define the treatments to apply on the location's name
-    tr_name = {'normalization': [lambda x: str(x),#Some names are casted to
+    tr_name = {'normalization': [str,         #Some names are casted to
                                                   #int/float, just correct it
                                  aln.simplify], # Simply all the names (remove
                                               #   punctuation, lower case, etc)
@@ -152,12 +152,12 @@
     print "Start computation"
     for ind, (alignid, targetid) in enumerate(neighbours):
         print '%3d' % ind, len(alignid), 'x', len(targetid)
-        mat, matched = subalign(alignset,   # The dataset to align
-                                targetset,  # The target dataset
-                                alignid,
-                                targetid,
-                                0.3,
-                                treatments)
+        _, matched = subalign(alignset,   # The dataset to align
+                              targetset,  # The target dataset
+                              alignid,
+                              targetid,
+                              0.3,
+                              treatments)
         write_results(matched, alignset, targetset, dpath('demo2_results'))
     print "Done, see the results in %s" % dpath('demo2_results')