[Matrix] Remove the unused defaultvalue
authorSimon Chabot <simon.chabot@logilab.fr>
Tue, 30 Oct 2012 16:41:53 +0100
changeset 65 5efd92896bbb
parent 64 b99068ec1163
child 66 221a299d9fb8
[Matrix] Remove the unused defaultvalue
alignment.py
matrix.py
test/test_alignment.py
--- a/alignment.py	Tue Oct 30 16:28:05 2012 +0100
+++ b/alignment.py	Tue Oct 30 16:41:53 2012 +0100
@@ -40,7 +40,6 @@
                           'distance': d1,
                           'distance_args': { 'arg1': arg11 },
                           'weighting': w,
-                          'defvalue': dv,
                           'matrix_normalize': True
                         }
 
@@ -53,10 +52,6 @@
             `weighting` is the weighting of the current attribut in regard to
             the others
 
-            `defvalue` is the default value to use, in case of the value is None
-            `matrix_normalize`, True means the values will be between 0 and 1,
-                else the raw value is kept
-
         `resultfile` is the name of the output csv.
     """
 
@@ -82,7 +77,6 @@
         t.setdefault('norm_args', {})
         t.setdefault('distance_args', {})
         t.setdefault('weighting', 1)
-        t.setdefault('defvalue', 100)
         t.setdefault('matrix_normalize', True)
 
     ralignset = normalizerset(alignset)
@@ -94,7 +88,6 @@
                 [ralignset[i][ind + 1] for i in xrange(len(ralignset))],
                 [rtargetset[i][ind + 1] for i in xrange(len(rtargetset))],
                 tr['distance'],
-                tr['defvalue'],
                 tr['matrix_normalize'],
                 tr['distance_args'])
         items.append(item)
--- a/matrix.py	Tue Oct 30 16:28:05 2012 +0100
+++ b/matrix.py	Tue Oct 30 16:41:53 2012 +0100
@@ -40,15 +40,14 @@
                  +----+----+
     """
 
-    def __init__(self, weighting, input1, input2, distance, defvalue,
-                 normalized = True, kargs = {}):
+    def __init__(self, weighting, input1, input2, distance, normalized = True, kargs = {}):
         self.distance = distance
         self._matrix = empty((len(input1), len(input2)), dtype='float32')
         self.size = self._matrix.shape
         self.normalized = normalized
-        self._compute(weighting, input1, input2, defvalue, kargs)
+        self._compute(weighting, input1, input2, kargs)
 
-    def _compute(self, weighting, input1, input2, defvalue, kargs):
+    def _compute(self, weighting, input1, input2, kargs):
         for i in xrange(self.size[0]):
             for j in xrange(self.size[1]):
                 d = 1
@@ -126,7 +125,7 @@
 
         - `items` is a list of tuples where each tuple is built as following :
 
-            `(weighting, input1, input2, distance_function, defvalue, normalize, args)`
+            `(weighting, input1, input2, distance_function, normalize, args)`
 
             * `input1` : a list of "things" (names, dates, numbers) to align on
                  `input2`. If a value is unknown, set it as `None`.
@@ -137,10 +136,6 @@
             * `weighting` : the weighting of the "things" computed, compared
                  with the others "things" of `items`
 
-            * `defvalue` : default value to use if an element of `input1` or
-                 `input2` is unknown. A good idea should be `defvalue` has an
-                 upper bound of the possible values to maximize the distance
-
             * `normalize` : boolean, if true, the matrix values will between 0
                 and 1, else the real result of `distance_function` will be
                 stored
--- a/test/test_alignment.py	Tue Oct 30 16:28:05 2012 +0100
+++ b/test/test_alignment.py	Tue Oct 30 16:41:53 2012 +0100
@@ -191,8 +191,7 @@
         self.input1 = [u'Victor Hugo', u'Albert Camus', 'Jean Valjean']
         self.input2 = [u'Victor Wugo', u'Albert Camus', 'Albert Camu']
         self.distance = levenshtein
-        self.matrix = Distancematrix(1, self.input1, self.input2, self.distance,
-                                     10, False)
+        self.matrix = Distancematrix(1, self.input1, self.input2, self.distance, False)
     def test_matrixconstruction(self):
         d = self.distance
         i1, i2 = self.input1, self.input2