Index: Orange/misc/counters.py
===================================================================
--- Orange/misc/counters.py	(revision 9671)
+++ Orange/misc/counters.py	(revision 9871)
@@ -6,74 +6,166 @@
 .. index:: misc
 .. index::
-   single: misc; counters
+     single: misc; counters
+
+:class:`Orange.misc.counters` contains a bunch of classes that generate sequences of various kinds.
+
 """
 
 class BooleanCounter:
-  def __init__(self, bits):
-    self.bits = bits
-    self.state = None
-
-  def __iter__(self):
-    if self.state:
-        return self
-    else:
-        return BooleanCounter(self.bits)
-    
-  def next(self):
-    if self.state:
-      for bit in range(self.bits-1, -1, -1):
-        self.state[bit] = (self.state[bit]+1) % 2
-        if self.state[bit]:
-          break
-      else:
+    """
+    A class which represents a boolean counter. The constructor is given the number of bits and during the
+    iteration the counter returns a list of that length with 0 and 1's in it.
+
+    One way to use the counter is within a for-loop:
+
+    >>> for r in Orange.misc.counters.BooleanCounter(3):
+    ...    print r
+    [0, 0, 0]
+    [0, 0, 1]
+    [0, 1, 0]
+    [0, 1, 1]
+    [1, 0, 0]
+    [1, 0, 1]
+    [1, 1, 0]
+    [1, 1, 1]
+
+    You can also call it manually.
+
+    >>> r = Orange.misc.counters.BooleanCounter(3)
+    >>> r.next()
+    [0, 0, 0]
+    >>> r.next()
+    [0, 0, 1]
+    >>> r.next()
+    [0, 1, 0]
+
+    .. attribute:: state
+    
+        The current counter state (the last result of a call to next) is also stored as attribute attribute.
+
+    """
+    
+    def __init__(self, bits):
+        """
+            :param bits: Number of bits.
+            :type bits: int
+        """
+        self.bits = bits
         self.state = None
-    else:
-      self.state = [0]*self.bits
-
-    if not self.state:
-        raise StopIteration, "BooleanCounter: counting finished"
-
-    return self.state
-
+
+    def __iter__(self):
+        if self.state:
+            return self
+        else:
+            return BooleanCounter(self.bits)
+        
+    def next(self):
+        """Return the next state of the counter."""
+        if self.state:
+            for bit in range(self.bits-1, -1, -1):
+                self.state[bit] = (self.state[bit]+1) % 2
+                if self.state[bit]:
+                    break
+            else:
+                self.state = None
+        else:
+            self.state = [0]*self.bits
+        if not self.state:
+            raise StopIteration, "BooleanCounter: counting finished"
+        return self.state
 
 class LimitedCounter:
-  def __init__(self, limits):
-    self.limits = limits
-    self.state = None
-    
-  def __iter__(self):
-    if self.state:
-        return self
-    else:
-        return LimitedCounter(self.limits)
-
-  def next(self):
-    if self.state:
-      i = len(self.limits)-1
-      while (i>=0) and (self.state[i]==self.limits[i]-1):
-        self.state[i] = 0
-        i -= 1
-      if i==-1:
+    """
+    This class is similar to :class:`~Orange.misc.counters.BooleanCounter` except that the digits do not count
+    from 0 to 1, but to the limits that are specified individually for each digit.
+
+    >>> for t in Orange.misc.counters.LimitedCounter([3, 5, 2]):
+    ...     print t
+    [0, 0, 0]
+    [0, 0, 1]
+    [0, 1, 0]
+    [0, 1, 1]
+    [0, 2, 0]
+    [0, 2, 1]
+    [0, 3, 0]
+    [0, 3, 1]
+    [0, 4, 0]
+    [0, 4, 1]
+    [1, 0, 0]
+    [1, 0, 1]
+    [1, 1, 0]
+    [1, 1, 1]
+
+    .. attribute:: state
+
+        The current counter state (the last result of a call to next) is also stored as attribute attribute.
+    """
+    
+    def __init__(self, limits):
+        """
+            :param limits: Domain size per bit position.
+            :type limits: list
+        """
+        self.limits = limits
         self.state = None
-      else:
-        self.state[i] += 1
-    else:
-      self.state = [0]*len(self.limits)
-  
-    if not self.state:
-      raise StopIteration, "LimitedCounter: counting finished"
-
-    return self.state
-
+        
+    def __iter__(self):
+        if self.state:
+            return self
+        else:
+            return LimitedCounter(self.limits)
+
+    def next(self):
+        """Return the next state of the counter."""
+        if self.state:
+            i = len(self.limits)-1
+            while (i>=0) and (self.state[i]==self.limits[i]-1):
+                self.state[i] = 0
+                i -= 1
+            if i==-1:
+                self.state = None
+            else:
+                self.state[i] += 1
+        else:
+            self.state = [0]*len(self.limits)
+    
+        if not self.state:
+            raise StopIteration, "LimitedCounter: counting finished"
+
+        return self.state
 
 class MofNCounter:
+    """
+    Counter returns all consecutive subset lists of length ``m`` out of ``n`` where ``m`` <= ``n``.
+
+    >>> for t in Orange.misc.counters.MofNCounter(3,7):
+    ...     print t
+    ...
+    [0, 1, 2]
+    [1, 2, 3]
+    [2, 3, 4]
+    [3, 4, 5]
+    [4, 5, 6]
+
+    .. attribute:: state
+
+        The current counter state (the last result of a call to next) is also stored as attribute attribute.
+    """
+    
     def __init__(self, m, n):
+        """
+        :param m: Length of subset list.
+        :type m: int
+
+        :param n: Total length.
+        :type n: int
+        """
         if m > n:
             raise TypeError, "Number of selected items exceeds the number of items"
-        
+                
         self.state = None
         self.m = m
         self.n = n
-        
+                
     def __iter__(self):
         if self.state:
@@ -81,6 +173,7 @@
         else:
             return MofNCounter(self.m, self.n)
-        
-    def next(self):
+                
+    def next(self):
+        """Return the next state of the counter."""
         if self.state:
             m, n, state = self.m, self.n, self.state
@@ -90,67 +183,130 @@
                     for place in range(place+1, m):
                         state[place] = state[place-1] + 1
-                    break
+                        break
+                else:
+                    self.state = None
+                    raise StopIteration, "MofNCounter: counting finished"
+        else:
+            self.state = range(self.m)
+        return self.state[:]
+                         
+class NondecreasingCounter:
+    """
+    Nondecreasing counter generates all non-decreasing integer sequences in which no numbers are skipped,
+    that is, if n is in the sequence, the sequence also includes all numbers between 0 and n. For instance,
+    [0, 0, 1, 0] is illegal since it decreases, and [0, 0, 2, 2] is illegal since it has 2 without having 1
+    first. Or, with an example
+
+    Nondecreasing counter generates all non-decreasing integer sequences in which no numbers are skipped,
+    that is, if ``n`` is in the sequence, the sequence also includes all numbers between 0 and ``n``. For instance,
+    [0, 0, 1, 0] is illegal since it decreases, and [0, 0, 2, 2] is illegal since it has 2 without having 1 first.
+    Or, with an example
+
+    >>> for t in Orange.misc.counters.NondecreasingCounter(4):
+    ...     print t
+    ...
+    [0, 0, 0, 0]
+    [0, 0, 0, 1]
+    [0, 0, 1, 1]
+    [0, 0, 1, 2]
+    [0, 1, 1, 1]
+    [0, 1, 1, 2]
+    [0, 1, 2, 2]
+    [0, 1, 2, 3]
+
+    .. attribute:: state
+
+        The current counter state (the last result of a call to next) is also stored as attribute attribute.
+    """
+    def __init__(self, places):
+        """
+            :param places: Number of places.
+            :type places: int
+        """
+        self.state=None
+        self.subcounter=None
+        self.places=places
+
+    def __iter__(self):
+        if self.state:
+            return self
+        else:
+            return NondecreasingCounter(self.places)
+
+    def next(self):
+        """Return the next state of the counter."""
+        if not self.subcounter:
+            self.subcounter=BooleanCounter(self.places-1)
+        if self.subcounter.next():
+            self.state=[0]
+            for add_one in self.subcounter.state:
+                self.state.append(self.state[-1]+add_one)
+        else:
+            self.state=None
+        if not self.state:
+            raise StopIteration, "NondecreasingCounter: counting finished"
+        return self.state
+
+
+class CanonicFuncCounter:
+    """
+    Returns all sequences of a given length where no numbers are skipped (see below) and none of
+    the generated sequence is equal to another if only the labels are changed. For instance, [0, 2, 2, 1]
+    and [1, 0, 0, 2] are considered equivalent: if we take the former and replace 0 by 1, 2
+    by 0 and 1 by 2 we get the second list.
+
+    The sequences generated are equivalent to all possible functions from a set of cardinality of the sequences length.
+
+    >>> for t in Orange.misc.counters.CanonicFuncCounter(4):
+    ...     print t
+    ...
+    [0, 0, 0, 0]
+    [0, 0, 0, 1]
+    [0, 0, 1, 0]
+    [0, 0, 1, 1]
+    [0, 0, 1, 2]
+    [0, 1, 0, 0]
+    [0, 1, 0, 1]
+    [0, 1, 0, 2]
+    [0, 1, 1, 0]
+    [0, 1, 1, 1]
+    [0, 1, 1, 2]
+    [0, 1, 2, 0]
+    [0, 1, 2, 1]
+    [0, 1, 2, 2]
+    [0, 1, 2, 3]
+
+    .. attribute:: state
+
+        The current counter state (the last result of a call to next) is also stored as attribute attribute.
+    """
+    def __init__(self, places):
+        """
+            :param places: Number of places.
+            :type places: int
+        """
+        self.places = places
+        self.state = None
+
+    def __iter__(self):
+        if self.state:
+            return self
+        else:
+            return CanonicFuncCounter(self.places)
+
+    def next(self):
+        """Return the next state of the counter."""
+        if self.state:
+            i = self.places-1
+            while (i>0) and (self.state[i]==max(self.state[:i])+1):
+                self.state[i] = 0
+                i -= 1
+            if i:
+                self.state[i] += 1
             else:
-                self.state = None
-                raise StopIteration, "MofNCounter: counting finished"
-        else:
-            self.state = range(self.m)
-            
-        return self.state[:]
-             
-class NondecreasingCounter:
-  def __init__(self, places):
-    self.state=None
-    self.subcounter=None
-    self.places=places
-
-  def __iter__(self):
-    if self.state:
-        return self
-    else:
-        return NondecreasingCounter(self.places)
-
-  def next(self):
-    if not self.subcounter:
-      self.subcounter=BooleanCounter(self.places-1)
-    if self.subcounter.next():
-      self.state=[0]
-      for add_one in self.subcounter.state:
-        self.state.append(self.state[-1]+add_one)
-    else:
-      self.state=None
-  
-    if not self.state:
-      raise StopIteration, "NondecreasingCounter: counting finished"
-
-    return self.state
-
-
-class CanonicFuncCounter:
-  def __init__(self, places):
-    self.places = places
-    self.state = None
-
-  def __iter__(self):
-    if self.state:
-        return self
-    else:
-        return CanonicFuncCounter(self.places)
-
-  def next(self):
-    if self.state:
-      i = self.places-1
-      while (i>0) and (self.state[i]==max(self.state[:i])+1):
-        self.state[i] = 0
-        i -= 1
-      if i:
-        self.state[i] += 1
-      else:
-        self.state=None
-    else:
-      self.state = [0]*self.places
-
-    if not self.state:
-      raise StopIteration, "CanonicFuncCounter: counting finished"
-    
-    return self.state
+                self.state=None
+        else:
+            self.state = [0]*self.places
+        if not self.state:
+            raise StopIteration, "CanonicFuncCounter: counting finished"
+        return self.state
Index: Orange/testing/regression/results_orange25/lasso-example.py.txt
===================================================================
--- Orange/testing/regression/results_orange25/lasso-example.py.txt	(revision 9850)
+++ Orange/testing/regression/results_orange25/lasso-example.py.txt	(revision 9867)
@@ -1,23 +1,23 @@
-Actual: 24.00, predicted: 27.76 
-Actual: 21.60, predicted: 24.95 
-Actual: 34.70, predicted: 28.26 
-Actual: 33.40, predicted: 27.37 
-Actual: 36.20, predicted: 27.34 
+Actual: 24.00, predicted: 26.54 
+Actual: 21.60, predicted: 23.85 
+Actual: 34.70, predicted: 26.35 
+Actual: 33.40, predicted: 25.73 
+Actual: 36.20, predicted: 25.55 
   Variable  Coeff Est  Std Error          p
  Intercept     22.533
-      CRIM     -0.130      0.016      0.000   ***
-       NOX     -1.520      0.980      0.200      
-        RM      2.993      0.803      0.000   ***
-   PTRATIO     -0.641      0.214      0.000   ***
-         B      0.007      0.002      0.000   ***
-     LSTAT     -0.205      0.101      0.000   ***
+        RM      1.962      0.859      0.000   ***
+       AGE     -0.007      0.003      0.160      
+   PTRATIO     -0.627      0.193      0.000   ***
+         B      0.002      0.002      0.240      
+     LSTAT     -0.174      0.103      0.000   ***
 Signif. codes:  0 *** 0.001 ** 0.01 * 0.05 . 0.1 empty 1
 
 
-For 7 variables the regression coefficient equals 0: 
+For 8 variables the regression coefficient equals 0: 
+CRIM
 ZN
 INDUS
 CHAS
-AGE
+NOX
 DIS
 RAD
Index: Orange/testing/regression/results_orange25/simple_tree_random_forest.py.txt
===================================================================
--- Orange/testing/regression/results_orange25/simple_tree_random_forest.py.txt	(revision 9854)
+++ Orange/testing/regression/results_orange25/simple_tree_random_forest.py.txt	(revision 9868)
@@ -4,4 +4,4 @@
 
 Runtimes:
-for_gain 0.093346118927
-for_simp 0.0253021717072
+for_gain 0.0942988395691
+for_simp 0.0253610610962
Index: Orange/testing/regression/results_orange25/svm-linear-weights.py.txt
===================================================================
--- Orange/testing/regression/results_orange25/svm-linear-weights.py.txt	(revision 9854)
+++ Orange/testing/regression/results_orange25/svm-linear-weights.py.txt	(revision 9870)
@@ -1,1 +1,1 @@
-defaultdict(<type 'float'>, {FloatVariable 'alpha 0': 0.19198054903386352, FloatVariable 'Elu 300': 0.15913983311663107, FloatVariable 'spo- mid': 3.2086605964825132, FloatVariable 'Elu 330': 0.11474308886955724, FloatVariable 'alpha 14': 0.18310901108005986, FloatVariable 'alpha 98': 0.21754881357923167, FloatVariable 'Elu 360': 0.16577258493775038, FloatVariable 'alpha 21': 0.030539018557891578, FloatVariable 'diau d': 0.44932601596409105, FloatVariable 'Elu 390': 0.1820761083768519, FloatVariable 'spo- early': 1.9466556509082333, FloatVariable 'alpha 28': 0.04645238275160125, FloatVariable 'cdc15 10': 0.11428450056762224, FloatVariable 'alpha 35': 0.21379911334384863, FloatVariable 'cdc15 30': 0.18270335600911874, FloatVariable 'alpha 42': 0.13641650791763626, FloatVariable 'spo5 2': 0.40417556232809326, FloatVariable 'cdc15 50': 0.24968263583989325, FloatVariable 'alpha 70': 0.26459268873021585, FloatVariable 'alpha 49': 0.16085715739160683, FloatVariable 'cdc15 70': 0.13876265882583333, FloatVariable 'alpha 105': 0.14088060621674625, FloatVariable 'alpha 56': 0.3367416107117914, FloatVariable 'cdc15 90': 0.32729758144823035, FloatVariable 'alpha 63': 0.18433878873311124, FloatVariable 'cdc15 110': 0.564756618474929, FloatVariable 'Elu 60': 0.36698713537474476, FloatVariable 'dtt 60': 0.5951914850021424, FloatVariable 'cdc15 130': 0.3658301477295572, FloatVariable 'dtt 120': 0.55305024494988, FloatVariable 'heat 80': 0.38909905042009185, FloatVariable 'cdc15 150': 0.693249161777514, FloatVariable 'alpha 77': 0.20088381949723239, FloatVariable 'cdc15 170': 0.44789694844623534, FloatVariable 'alpha 91': 0.1905674816738207, FloatVariable 'cdc15 190': 0.16956982427965123, FloatVariable 'cold 40': 0.3092287272528724, FloatVariable 'alpha 112': 0.19329749923741518, FloatVariable 'cdc15 210': 0.15183429673463036, FloatVariable 'cold 160': 0.6947037871090163, FloatVariable 'Elu 90': 0.3834942300173535, FloatVariable 'cdc15 230': 0.5474715182870784, FloatVariable 'heat 0': 0.19091815990337407, FloatVariable 'heat 10': 1.000320207469925, FloatVariable 'diau a': 0.14935761521655416, FloatVariable 'cdc15 250': 0.3573777070361102, FloatVariable 'alpha 119': 0.1699365258012951, FloatVariable 'cdc15 270': 0.21951931922594184, FloatVariable 'Elu 0': 0.8466167037587657, FloatVariable 'alpha 7': 0.06557659077448137, FloatVariable 'alpha 84': 0.1308234316119738, FloatVariable 'heat 40': 0.4580618143377812, FloatVariable 'spo 0': 0.13024372486415015, FloatVariable 'diau b': 0.23473821977067888, FloatVariable 'diau e': 0.864767371223623, FloatVariable 'spo 2': 0.7078062232168753, FloatVariable 'Elu 180': 0.42425268429856355, FloatVariable 'diau f': 1.4452997087693935, FloatVariable 'spo 5': 1.0683498605674933, FloatVariable 'Elu 30': 0.4786304184632838, FloatVariable 'Elu 120': 0.5939764872379445, FloatVariable 'diau g': 2.248793727194904, FloatVariable 'heat 160': 0.3192185000510415, FloatVariable 'spo 7': 0.8081568079276176, FloatVariable 'Elu 270': 0.33471969574325466, FloatVariable 'Elu 150': 0.5965599387054419, FloatVariable 'dtt 15': 0.49451797411099035, FloatVariable 'spo 9': 0.2498282401589412, FloatVariable 'cold 20': 0.4097605043285248, FloatVariable 'spo 11': 0.20615575833508282, FloatVariable 'Elu 210': 0.12396520046361383, FloatVariable 'dtt 30': 0.5838556086306895, FloatVariable 'Elu 240': 0.2093390824178926, FloatVariable 'diau c': 0.13741762346585432, FloatVariable 'spo5 7': 0.26780459416067937, FloatVariable 'cdc15 290': 0.24965577080121784, FloatVariable 'cold 0': 0.27980454530046744, FloatVariable 'spo5 11': 1.200079459496442, FloatVariable 'heat 20': 0.9867456006798212})
+defaultdict(<type 'float'>, {FloatVariable 'alpha 0': 0.19198054903386352, FloatVariable 'Elu 300': 0.15913983311663107, FloatVariable 'spo- mid': 3.2086605964825132, FloatVariable 'Elu 330': 0.11474308886955724, FloatVariable 'alpha 14': 0.18310901108005986, FloatVariable 'alpha 98': 0.21754881357923167, FloatVariable 'Elu 360': 0.16577258493775038, FloatVariable 'Elu 180': 0.42425268429856355, FloatVariable 'alpha 21': 0.030539018557891578, FloatVariable 'Elu 30': 0.4786304184632838, FloatVariable 'Elu 390': 0.1820761083768519, FloatVariable 'spo- early': 1.9466556509082333, FloatVariable 'alpha 28': 0.04645238275160125, FloatVariable 'cdc15 10': 0.11428450056762224, FloatVariable 'alpha 35': 0.21379911334384863, FloatVariable 'cdc15 30': 0.18270335600911874, FloatVariable 'alpha 42': 0.13641650791763626, FloatVariable 'cdc15 50': 0.24968263583989325, FloatVariable 'alpha 70': 0.26459268873021585, FloatVariable 'alpha 49': 0.16085715739160683, FloatVariable 'cdc15 70': 0.13876265882583333, FloatVariable 'alpha 105': 0.14088060621674625, FloatVariable 'diau b': 0.23473821977067888, FloatVariable 'alpha 56': 0.3367416107117914, FloatVariable 'cdc15 90': 0.32729758144823035, FloatVariable 'alpha 63': 0.18433878873311124, FloatVariable 'cdc15 110': 0.564756618474929, FloatVariable 'Elu 60': 0.36698713537474476, FloatVariable 'dtt 60': 0.5951914850021424, FloatVariable 'cdc15 130': 0.3658301477295572, FloatVariable 'alpha 77': 0.20088381949723239, FloatVariable 'heat 80': 0.38909905042009185, FloatVariable 'cdc15 150': 0.693249161777514, FloatVariable 'alpha 84': 0.1308234316119738, FloatVariable 'cdc15 170': 0.44789694844623534, FloatVariable 'cold 20': 0.4097605043285248, FloatVariable 'cdc15 190': 0.16956982427965123, FloatVariable 'cold 40': 0.3092287272528724, FloatVariable 'alpha 112': 0.19329749923741518, FloatVariable 'cdc15 210': 0.15183429673463036, FloatVariable 'cold 160': 0.6947037871090163, FloatVariable 'diau f': 1.4452997087693935, FloatVariable 'cdc15 230': 0.5474715182870784, FloatVariable 'heat 0': 0.19091815990337407, FloatVariable 'diau a': 0.14935761521655416, FloatVariable 'heat 160': 0.3192185000510415, FloatVariable 'cdc15 250': 0.3573777070361102, FloatVariable 'heat 40': 0.4580618143377812, FloatVariable 'cdc15 270': 0.21951931922594184, FloatVariable 'spo5 2': 0.40417556232809326, FloatVariable 'Elu 0': 0.8466167037587657, FloatVariable 'alpha 7': 0.06557659077448137, FloatVariable 'cold 0': 0.27980454530046744, FloatVariable 'diau d': 0.44932601596409105, FloatVariable 'spo 0': 0.13024372486415015, FloatVariable 'alpha 119': 0.1699365258012951, FloatVariable 'diau e': 0.864767371223623, FloatVariable 'spo 2': 0.7078062232168753, FloatVariable 'heat 10': 1.000320207469925, FloatVariable 'spo 5': 1.0683498605674933, FloatVariable 'Elu 120': 0.5939764872379445, FloatVariable 'diau g': 2.248793727194904, FloatVariable 'spo 7': 0.8081568079276176, FloatVariable 'Elu 150': 0.5965599387054419, FloatVariable 'Elu 90': 0.3834942300173535, FloatVariable 'spo 9': 0.2498282401589412, FloatVariable 'dtt 30': 0.5838556086306895, FloatVariable 'alpha 91': 0.1905674816738207, FloatVariable 'spo 11': 0.20615575833508282, FloatVariable 'Elu 210': 0.12396520046361383, FloatVariable 'cdc15 290': 0.24965577080121784, FloatVariable 'dtt 15': 0.49451797411099035, FloatVariable 'Elu 240': 0.2093390824178926, FloatVariable 'diau c': 0.13741762346585432, FloatVariable 'spo5 7': 0.26780459416067937, FloatVariable 'dtt 120': 0.55305024494988, FloatVariable 'Elu 270': 0.33471969574325466, FloatVariable 'spo5 11': 1.200079459496442, FloatVariable 'heat 20': 0.9867456006798212})
Index: docs/reference/rst/code/mds-euclid-torgerson-3d.py
===================================================================
--- docs/reference/rst/code/mds-euclid-torgerson-3d.py	(revision 9823)
+++ docs/reference/rst/code/mds-euclid-torgerson-3d.py	(revision 9866)
@@ -11,9 +11,9 @@
 
 # Construct a distance matrix using Euclidean distance
-dist = Orange.distance.instances.EuclideanConstructor(iris)
+dist = Orange.distance.Euclidean(iris)
 matrix = Orange.core.SymMatrix(len(iris))
 matrix.setattr('items', iris)
 for i in range(len(iris)):
-    for j in range(i+1):
+    for j in range(i + 1):
         matrix[i, j] = dist(iris[i], iris[j])
 
Index: docs/reference/rst/code/unusedValues.py
===================================================================
--- docs/reference/rst/code/unusedValues.py	(revision 9754)
+++ docs/reference/rst/code/unusedValues.py	(revision 9869)
@@ -2,5 +2,5 @@
 data = Orange.data.Table("unusedValues")
 
-new_variables = [Orange.core.RemoveUnusedValues(var, data) for variable in data.domain.variables]
+new_variables = [Orange.core.RemoveUnusedValues(var, data) for var in data.domain.variables]
 
 print
