prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Validation: Remove deprecated constructor calls
  **Describe the bug**
  Our tests (and code?) use deprecated calls, resulting in many of the following lines in output of tests:
  `DeprecationWarning: calling Validation's constructor with data and learners is deprecated;`
  
  **To Reproduce**
  Run tests or look at travis.
  
  </issue>
  <code>
  [start of Orange/ensembles/stack.py]
  1 import numpy as np
  2 
  3 from Orange.base import Learner, Model
  4 from Orange.modelling import Fitter
  5 from Orange.classification import LogisticRegressionLearner
  6 from Orange.classification.base_classification import LearnerClassification
  7 from Orange.data import Domain, ContinuousVariable, Table
  8 from Orange.evaluation import CrossValidation
  9 from Orange.regression import RidgeRegressionLearner
  10 from Orange.regression.base_regression import LearnerRegression
  11 
  12 
  13 __all__ = ['StackedLearner', 'StackedClassificationLearner',
  14            'StackedRegressionLearner', 'StackedFitter']
  15 
  16 
  17 class StackedModel(Model):
  18     def __init__(self, models, aggregate, use_prob=True, domain=None):
  19         super().__init__(domain=domain)
  20         self.models = models
  21         self.aggregate = aggregate
  22         self.use_prob = use_prob
  23 
  24     def predict_storage(self, data):
  25         if self.use_prob:
  26             probs = [m(data, Model.Probs) for m in self.models]
  27             X = np.hstack(probs)
  28         else:
  29             pred = [m(data) for m in self.models]
  30             X = np.column_stack(pred)
  31         Y = np.repeat(np.nan, X.shape[0])
  32         stacked_data = data.transform(self.aggregate.domain)
  33         stacked_data.X = X
  34         stacked_data.Y = Y
  35         return self.aggregate(
  36             stacked_data, Model.ValueProbs if self.use_prob else Model.Value)
  37 
  38 
  39 class StackedLearner(Learner):
  40     """
  41     Constructs a stacked model by fitting an aggregator
  42     over the results of base models.
  43 
  44     K-fold cross-validation is used to get predictions of the base learners
  45     and fit the aggregator to obtain a stacked model.
  46 
  47     Args:
  48         learners (list):
  49             list of `Learner`s used for base models
  50 
  51         aggregate (Learner):
  52             Learner used to fit the meta model, aggregating predictions
  53             of base models
  54 
  55         k (int):
  56             number of folds for cross-validation
  57 
  58     Returns:
  59         instance of StackedModel
  60     """
  61 
  62     __returns__ = StackedModel
  63 
  64     def __init__(self, learners, aggregate, k=5, preprocessors=None):
  65         super().__init__(preprocessors=preprocessors)
  66         self.learners = learners
  67         self.aggregate = aggregate
  68         self.k = k
  69         self.params = vars()
  70 
  71     def fit_storage(self, data):
  72         res = CrossValidation(data, self.learners, k=self.k)
  73         if data.domain.class_var.is_discrete:
  74             X = np.hstack(res.probabilities)
  75             use_prob = True
  76         else:
  77             X = res.predicted.T
  78             use_prob = False
  79         dom = Domain([ContinuousVariable('f{}'.format(i + 1))
  80                       for i in range(X.shape[1])],
  81                      data.domain.class_var)
  82         stacked_data = data.transform(dom)
  83         stacked_data.X = X
  84         stacked_data.Y = res.actual
  85         models = [l(data) for l in self.learners]
  86         aggregate_model = self.aggregate(stacked_data)
  87         return StackedModel(models, aggregate_model, use_prob=use_prob,
  88                             domain=data.domain)
  89 
  90 
  91 class StackedClassificationLearner(StackedLearner, LearnerClassification):
  92     """
  93     Subclass of StackedLearner intended for classification tasks.
  94 
  95     Same as the super class, but has a default
  96     classification-specific aggregator (`LogisticRegressionLearner`).
  97     """
  98 
  99     def __init__(self, learners, aggregate=LogisticRegressionLearner(), k=5,
  100                  preprocessors=None):
  101         super().__init__(learners, aggregate, k=k, preprocessors=preprocessors)
  102 
  103 
  104 class StackedRegressionLearner(StackedLearner, LearnerRegression):
  105     """
  106     Subclass of StackedLearner intended for regression tasks.
  107 
  108     Same as the super class, but has a default
  109     regression-specific aggregator (`RidgeRegressionLearner`).
  110     """
  111     def __init__(self, learners, aggregate=RidgeRegressionLearner(), k=5,
  112                  preprocessors=None):
  113         super().__init__(learners, aggregate, k=k, preprocessors=preprocessors)
  114 
  115 
  116 class StackedFitter(Fitter):
  117     __fits__ = {'classification': StackedClassificationLearner,
  118                 'regression': StackedRegressionLearner}
  119 
  120     def __init__(self, learners, **kwargs):
  121         kwargs['learners'] = learners
  122         super().__init__(**kwargs)
  123 
  124 
  125 if __name__ == '__main__':
  126     import Orange
  127     iris = Table('iris')
  128     knn = Orange.modelling.KNNLearner()
  129     tree = Orange.modelling.TreeLearner()
  130     sl = StackedFitter([tree, knn])
  131     m = sl(iris[::2])
  132     print(m(iris[1::2], Model.Value))
  133 
  134     housing = Table('housing')
  135     sl = StackedFitter([tree, knn])
  136     m = sl(housing[::2])
  137     print(list(zip(housing[1:10:2].Y, m(housing[1:10:2], Model.Value))))
  138
  [end of Orange/ensembles/stack.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/Orange/ensembles/stack.py b/Orange/ensembles/stack.py
  --- a/Orange/ensembles/stack.py
  +++ b/Orange/ensembles/stack.py
  @@ -69,7 +69,8 @@
           self.params = vars()
   
       def fit_storage(self, data):
  -        res = CrossValidation(data, self.learners, k=self.k)
  +        cv = CrossValidation(k=self.k)
  +        res = cv(data, self.learners)
           if data.domain.class_var.is_discrete:
               X = np.hstack(res.probabilities)
               use_prob = True
  
verification_info: {"golden_diff": "diff --git a/Orange/ensembles/stack.py b/Orange/ensembles/stack.py\n--- a/Orange/ensembles/stack.py\n+++ b/Orange/ensembles/stack.py\n@@ -69,7 +69,8 @@\n         self.params = vars()\n \n     def fit_storage(self, data):\n-        res = CrossValidation(data, self.learners, k=self.k)\n+        cv = CrossValidation(k=self.k)\n+        res = cv(data, self.learners)\n         if data.domain.class_var.is_discrete:\n             X = np.hstack(res.probabilities)\n             use_prob = True\n", "issue": "Validation: Remove deprecated constructor calls\n**Describe the bug**\r\nOur tests (and code?) use deprecated calls, resulting in many of the following lines in output of tests:\r\n`DeprecationWarning: calling Validation's constructor with data and learners is deprecated;`\r\n\r\n**To Reproduce**\r\nRun tests or look at travis.\n", "before_files": [{"content": "import numpy as np\n\nfrom Orange.base import Learner, Model\nfrom Orange.modelling import Fitter\nfrom Orange.classification import LogisticRegressionLearner\nfrom Orange.classification.base_classification import LearnerClassification\nfrom Orange.data import Domain, ContinuousVariable, Table\nfrom Orange.evaluation import CrossValidation\nfrom Orange.regression import RidgeRegressionLearner\nfrom Orange.regression.base_regression import LearnerRegression\n\n\n__all__ = ['StackedLearner', 'StackedClassificationLearner',\n           'StackedRegressionLearner', 'StackedFitter']\n\n\nclass StackedModel(Model):\n    def __init__(self, models, aggregate, use_prob=True, domain=None):\n        super().__init__(domain=domain)\n        self.models = models\n        self.aggregate = aggregate\n        self.use_prob = use_prob\n\n    def predict_storage(self, data):\n        if self.use_prob:\n            probs = [m(data, Model.Probs) for m in self.models]\n            X = np.hstack(probs)\n        else:\n            pred = [m(data) for m in self.models]\n            X = np.column_stack(pred)\n        Y = np.repeat(np.nan, X.shape[0])\n        stacked_data = data.transform(self.aggregate.domain)\n        stacked_data.X = X\n        stacked_data.Y = Y\n        return self.aggregate(\n            stacked_data, Model.ValueProbs if self.use_prob else Model.Value)\n\n\nclass StackedLearner(Learner):\n    \"\"\"\n    Constructs a stacked model by fitting an aggregator\n    over the results of base models.\n\n    K-fold cross-validation is used to get predictions of the base learners\n    and fit the aggregator to obtain a stacked model.\n\n    Args:\n        learners (list):\n            list of `Learner`s used for base models\n\n        aggregate (Learner):\n            Learner used to fit the meta model, aggregating predictions\n            of base models\n\n        k (int):\n            number of folds for cross-validation\n\n    Returns:\n        instance of StackedModel\n    \"\"\"\n\n    __returns__ = StackedModel\n\n    def __init__(self, learners, aggregate, k=5, preprocessors=None):\n        super().__init__(preprocessors=preprocessors)\n        self.learners = learners\n        self.aggregate = aggregate\n        self.k = k\n        self.params = vars()\n\n    def fit_storage(self, data):\n        res = CrossValidation(data, self.learners, k=self.k)\n        if data.domain.class_var.is_discrete:\n            X = np.hstack(res.probabilities)\n            use_prob = True\n        else:\n            X = res.predicted.T\n            use_prob = False\n        dom = Domain([ContinuousVariable('f{}'.format(i + 1))\n                      for i in range(X.shape[1])],\n                     data.domain.class_var)\n        stacked_data = data.transform(dom)\n        stacked_data.X = X\n        stacked_data.Y = res.actual\n        models = [l(data) for l in self.learners]\n        aggregate_model = self.aggregate(stacked_data)\n        return StackedModel(models, aggregate_model, use_prob=use_prob,\n                            domain=data.domain)\n\n\nclass StackedClassificationLearner(StackedLearner, LearnerClassification):\n    \"\"\"\n    Subclass of StackedLearner intended for classification tasks.\n\n    Same as the super class, but has a default\n    classification-specific aggregator (`LogisticRegressionLearner`).\n    \"\"\"\n\n    def __init__(self, learners, aggregate=LogisticRegressionLearner(), k=5,\n                 preprocessors=None):\n        super().__init__(learners, aggregate, k=k, preprocessors=preprocessors)\n\n\nclass StackedRegressionLearner(StackedLearner, LearnerRegression):\n    \"\"\"\n    Subclass of StackedLearner intended for regression tasks.\n\n    Same as the super class, but has a default\n    regression-specific aggregator (`RidgeRegressionLearner`).\n    \"\"\"\n    def __init__(self, learners, aggregate=RidgeRegressionLearner(), k=5,\n                 preprocessors=None):\n        super().__init__(learners, aggregate, k=k, preprocessors=preprocessors)\n\n\nclass StackedFitter(Fitter):\n    __fits__ = {'classification': StackedClassificationLearner,\n                'regression': StackedRegressionLearner}\n\n    def __init__(self, learners, **kwargs):\n        kwargs['learners'] = learners\n        super().__init__(**kwargs)\n\n\nif __name__ == '__main__':\n    import Orange\n    iris = Table('iris')\n    knn = Orange.modelling.KNNLearner()\n    tree = Orange.modelling.TreeLearner()\n    sl = StackedFitter([tree, knn])\n    m = sl(iris[::2])\n    print(m(iris[1::2], Model.Value))\n\n    housing = Table('housing')\n    sl = StackedFitter([tree, knn])\n    m = sl(housing[::2])\n    print(list(zip(housing[1:10:2].Y, m(housing[1:10:2], Model.Value))))\n", "path": "Orange/ensembles/stack.py"}]}