internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: biolab/orange3

Issue:
Sample data: remaining data output is wrong with replicable sampling
##### Orange version
master


##### Actual behavior
I was using iris or titanic on input. I was using "Fixed proportion of data" type of sampling. If I do not check "Replicable sampling" then len(sample) + len(remaining) = len(data).

If I do check "Replicable sampling" then the length of Remaining data output is wrong.

Solution should include tests. Tests also need to check whether the remaining data overlaps with sampled data.



Discussion:

Resolving patch:
diff --git a/Orange/widgets/data/owdatasampler.py b/Orange/widgets/data/owdatasampler.py
--- a/Orange/widgets/data/owdatasampler.py
+++ b/Orange/widgets/data/owdatasampler.py
@@ -377,7 +377,8 @@ def __init__(self, p=0, stratified=False, random_state=None):
 
     def __call__(self, table):
         n = int(math.ceil(len(table) * self.p))
-        return SampleRandomN(n, self.stratified, self.random_state)(table)
+        return SampleRandomN(n, self.stratified,
+                             random_state=self.random_state)(table)
 
 
 class SampleBootstrap(Reprable):


Test patch:
diff --git a/Orange/widgets/data/tests/test_owdatasampler.py b/Orange/widgets/data/tests/test_owdatasampler.py
--- a/Orange/widgets/data/tests/test_owdatasampler.py
+++ b/Orange/widgets/data/tests/test_owdatasampler.py
@@ -10,6 +10,7 @@ class TestOWDataSampler(WidgetTest):
     def setUpClass(cls):
         super().setUpClass()
         cls.iris = Table("iris")
+        cls.zoo = Table("zoo")
 
     def setUp(self):
         self.widget = self.create_widget(OWDataSampler)  # type: OWDataSampler
@@ -59,3 +60,27 @@ def test_bootstrap(self):
     def select_sampling_type(self, sampling_type):
         buttons = self.widget.controls.sampling_type.group.buttons()
         buttons[sampling_type].click()
+
+    def test_no_intersection_in_outputs(self):
+        """ Check whether outputs intersect and whether length of outputs sums
+        to length of original data """
+        self.send_signal("Data", self.zoo)
+        w = self.widget
+        sampling_types = [w.FixedProportion, w.FixedSize, w.CrossValidation]
+
+        for replicable in [True, False]:
+            for stratified in [True, False]:
+                for sampling_type in sampling_types:
+                    self.widget.cb_seed.setChecked(replicable)
+                    self.widget.cb_stratify.setChecked(stratified)
+                    self.select_sampling_type(sampling_type)
+                    self.widget.commit()
+
+                    sample = self.get_output("Data Sample")
+                    other = self.get_output("Remaining Data")
+                    self.assertEqual(len(self.zoo), len(sample) + len(other))
+                    self.assertNoIntersection(sample, other)
+
+    def assertNoIntersection(self, sample, other):
+        for inst in sample:
+            self.assertNotIn(inst, other)
Repository: biolab/orange3

Issue:
HiDPI not supported
<!--
This is an issue template. Please fill in the relevant details in the
sections below.
-->

##### Orange version
<!-- From menu _Help→About→Version_ or code `Orange.version.full_version` -->
3.3.11

##### Expected behavior
When I open Orange, I expect to be able to read and click things.


##### Actual behavior
Everything is rendered so small that it's nearly impossible to click or read anything on screen


##### Steps to reproduce the behavior
Load Orange into a 4k screen


##### Additional info (worksheets, data, screenshots, ...)
![untitled](https://cloud.githubusercontent.com/assets/9716643/22879338/d71c7fb6-f1dd-11e6-971b-7557bbf7c3c4.png)




Discussion:
Are you using windows? Do you have content scaling turned on? If so, to what percentage? (trying to recreate the exact environment)
Heya sorry, I'm indeed on Windows 10 build 1677. I've turned content scaling on and off, using all percentages, but even at 350% scaling it's still barely readable. Current screenshot is at 250%.

Resolving patch:
diff --git a/Orange/canvas/application/application.py b/Orange/canvas/application/application.py
--- a/Orange/canvas/application/application.py
+++ b/Orange/canvas/application/application.py
@@ -12,6 +12,9 @@ class CanvasApplication(QApplication):
     fileOpenRequest = Signal(QUrl)
 
     def __init__(self, argv):
+        if hasattr(Qt, "AA_EnableHighDpiScaling"):
+            # Turn on HighDPI support when available
+            QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
         QApplication.__init__(self, argv)
         self.setAttribute(Qt.AA_DontShowIconsInMenus, True)
 


Test patch:
Repository: biolab/orange3

Issue:
Paint Data: Labels combo box too large
##### Orange version
3.3.12

##### Expected behavior
The Labels combo box is too large, preventing this widget to be smaller in size. Please reduce the size of the combo box to one third (enough to, say, accommodate for three labels).


Discussion:

Resolving patch:
diff --git a/Orange/widgets/data/owpaintdata.py b/Orange/widgets/data/owpaintdata.py
--- a/Orange/widgets/data/owpaintdata.py
+++ b/Orange/widgets/data/owpaintdata.py
@@ -12,7 +12,7 @@
     QPalette
 )
 from AnyQt.QtWidgets import (
-    QListView, QSizePolicy, QAction, QUndoCommand, QUndoStack, QGridLayout,
+    QSizePolicy, QAction, QUndoCommand, QUndoStack, QGridLayout,
     QFormLayout, QToolButton, QActionGroup
 )
 
@@ -846,11 +846,8 @@ def _init_ui(self):
         gui.separator(namesBox)
 
         gui.widgetLabel(namesBox, "Labels")
-        self.classValuesView = listView = QListView(
-            selectionMode=QListView.SingleSelection,
-            sizePolicy=QSizePolicy(QSizePolicy.Ignored,
-                                   QSizePolicy.Maximum)
-        )
+        self.classValuesView = listView = gui.ListViewWithSizeHint(
+            preferred_size=(-1, 30))
         listView.setModel(self.class_model)
         itemmodels.select_row(listView, 0)
         namesBox.layout().addWidget(listView)
@@ -940,7 +937,6 @@ def _init_ui(self):
             tBox, self, "Reset to Input Data", self.reset_to_input)
         self.btResetToInput.setDisabled(True)
 
-        gui.rubber(self.controlArea)
         gui.auto_commit(self.left_side, self, "autocommit",
                         "Send")
 
@@ -1287,7 +1283,7 @@ def commit(self):
 
     def sizeHint(self):
         sh = super().sizeHint()
-        return sh.expandedTo(QSize(900, 650))
+        return sh.expandedTo(QSize(570, 690))
 
     def onDeleteWidget(self):
         self.plot.clear()
diff --git a/Orange/widgets/gui.py b/Orange/widgets/gui.py
--- a/Orange/widgets/gui.py
+++ b/Orange/widgets/gui.py
@@ -1057,7 +1057,8 @@ def __init__(self, *args, preferred_size=None, **kwargs):
         self.preferred_size = preferred_size
 
     def sizeHint(self):
-        return self.preferred_size or super().sizeHint()
+        return self.preferred_size if self.preferred_size is not None \
+            else super().sizeHint()
 
 
 def listView(widget, master, value=None, model=None, box=None, callback=None,


Test patch:
Repository: biolab/orange3

Issue:
Workflows open with the last opened file
##### Orange version
3.4.dev0+45307ad

##### Expected behavior
Workflows open with the file the workflow was created with.


##### Actual behavior
Workflows open with the last opened file instead.


##### Steps to reproduce the behavior
Create a schema. File (_iris.tab_) --> Data Table. Add a single File widget with _housing.tab_. Save.
Reopen the schema. Now both File widgets open with housing.tab.


##### Additional info (worksheets, data, screenshots, ...)





Discussion:
Or simply open a random (non-iris) data set with File and open one the example schemas. They open with your non-iris file even when they should be iris.

Resolving patch:
diff --git a/Orange/widgets/settings.py b/Orange/widgets/settings.py
--- a/Orange/widgets/settings.py
+++ b/Orange/widgets/settings.py
@@ -142,13 +142,14 @@ def initialize(self, instance, data=None):
         self._initialize_providers(instance, data)
 
     def _initialize_settings(self, instance, data):
+        if data is None:
+            data = {}
         for name, setting in self.settings.items():
-            if data and name in data:
-                setattr(instance, name, data[name])
-            elif isinstance(setting.default, _IMMUTABLES):
-                setattr(instance, name, setting.default)
+            value = data.get(name, setting.default)
+            if isinstance(value, _IMMUTABLES):
+                setattr(instance, name, value)
             else:
-                setattr(instance, name, copy.copy(setting.default))
+                setattr(instance, name, copy.copy(value))
 
     def _initialize_providers(self, instance, data):
         if not data:


Test patch:
diff --git a/Orange/widgets/tests/test_settings_handler.py b/Orange/widgets/tests/test_settings_handler.py
--- a/Orange/widgets/tests/test_settings_handler.py
+++ b/Orange/widgets/tests/test_settings_handler.py
@@ -266,6 +266,19 @@ def test_pack_settings_stores_version(self):
         settings = handler.pack_data(widget)
         self.assertIn(VERSION_KEY, settings)
 
+    def test_initialize_copies_mutables(self):
+        handler = SettingsHandler()
+        handler.bind(SimpleWidget)
+        handler.defaults = dict(list_setting=[])
+
+        widget = SimpleWidget()
+        handler.initialize(widget)
+
+        widget2 = SimpleWidget()
+        handler.initialize(widget2)
+
+        self.assertNotEqual(id(widget.list_setting), id(widget2.list_setting))
+
     @contextmanager
     def override_default_settings(self, widget, defaults=None):
         if defaults is None:
@@ -292,6 +305,7 @@ class SimpleWidget:
 
     setting = Setting(42)
     schema_only_setting = Setting(None, schema_only=True)
+    list_setting = Setting([])
     non_setting = 5
 
     component = SettingProvider(Component)
Repository: biolab/orange3

Issue:
Randomize should work on sparse
<!--
This is an issue template. Please fill in the relevant details in the
sections below.
-->

##### Orange version
<!-- From menu _Help→About→Version_ or code `Orange.version.full_version` -->
3.5.dev

##### Expected behavior
Randomize should work on sparse.


##### Actual behavior
Randomize fails on sparse.


##### Steps to reproduce the behavior
Corpus - Bag of Words - Randomize.


##### Additional info (worksheets, data, screenshots, ...)





Discussion:

Resolving patch:
diff --git a/Orange/data/table.py b/Orange/data/table.py
--- a/Orange/data/table.py
+++ b/Orange/data/table.py
@@ -702,9 +702,6 @@ def __getitem__(self, key):
         return self.from_table(domain, self, row_idx)
 
     def __setitem__(self, key, value):
-        if not self._check_all_dense():
-            raise ValueError(
-                "Assignment to rows of sparse data is not supported")
         if not isinstance(key, tuple):
             if isinstance(value, Real):
                 self.X[key, :] = value
diff --git a/Orange/preprocess/preprocess.py b/Orange/preprocess/preprocess.py
--- a/Orange/preprocess/preprocess.py
+++ b/Orange/preprocess/preprocess.py
@@ -5,6 +5,7 @@
 """
 import numpy as np
 import sklearn.preprocessing as skl_preprocessing
+from sklearn.utils import shuffle as skl_shuffle
 import bottleneck as bn
 
 import Orange.data
@@ -353,20 +354,15 @@ def __call__(self, data):
         new_data.ensure_copy()
 
         if self.rand_type & Randomize.RandomizeClasses:
-            self.randomize(new_data.Y)
+            new_data.Y = self.randomize(new_data.Y)
         if self.rand_type & Randomize.RandomizeAttributes:
-            self.randomize(new_data.X)
+            new_data.X = self.randomize(new_data.X)
         if self.rand_type & Randomize.RandomizeMetas:
-            self.randomize(new_data.metas)
+            new_data.metas = self.randomize(new_data.metas)
         return new_data
 
     def randomize(self, table):
-        np.random.seed(self.rand_seed)
-        if len(table.shape) > 1:
-            for i in range(table.shape[1]):
-                np.random.shuffle(table[:, i])
-        else:
-            np.random.shuffle(table)
+        return skl_shuffle(table, random_state=self.rand_seed)
 
 
 class ProjectPCA(Preprocess):


Test patch:
diff --git a/Orange/tests/test_sparse_table.py b/Orange/tests/test_sparse_table.py
--- a/Orange/tests/test_sparse_table.py
+++ b/Orange/tests/test_sparse_table.py
@@ -37,9 +37,7 @@ def test_clear(self):
             super().test_clear()
 
     def test_row_assignment(self):
-        with self.assertRaises(ValueError):
-            super().test_row_assignment()
+        super().test_row_assignment()
 
     def test_value_assignment(self):
-        with self.assertRaises(ValueError):
-            super().test_value_assignment()
+        super().test_value_assignment()
Repository: biolab/orange3

Issue:
Nomogram Calls `update_scene` Too Many Times
<!--
This is an issue template. Please fill in the relevant details in the
sections below.
-->

##### Orange version
<!-- From menu _Help→About→Version_ or code `Orange.version.full_version` -->
3.5.dev

##### Expected behavior
Nomogram's method `update_scene` is called just once when new widget is created. 

##### Actual behavior
Nomogram's method `update_scene` is called four times. Since `update_scene` is quite slow for data sets with many attributes — it takes about 3.3s on a moderately sized BoW data of shape (140, 3000) — it would be nice if it wouldn't need to be called four times before showing Nomogram. 


##### Steps to reproduce the behavior
At the beginning of Nomogram's `update_scene` add  `print('updating scene ...')`. Then train logistic regression on some data and connect it to Nomogram. Just after it's connected I see the first `updating scene ...'` log. When I open the widget I see three more entries. 
 


##### Additional info (worksheets, data, screenshots, ...)

![screen shot 2017-04-06 at 18 22 05](https://cloud.githubusercontent.com/assets/713026/24764886/1b6dedc6-1af6-11e7-9fa6-3e790b7b7294.png)



Discussion:

Resolving patch:
diff --git a/Orange/widgets/visualize/ownomogram.py b/Orange/widgets/visualize/ownomogram.py
--- a/Orange/widgets/visualize/ownomogram.py
+++ b/Orange/widgets/visualize/ownomogram.py
@@ -652,6 +652,7 @@ def __init__(self):
         self.hidden_vertical_line = None
         self.old_target_class_index = self.target_class_index
         self.markers_set = False
+        self.repaint = False
 
         # GUI
         box = gui.vBox(self.controlArea, "Target class")
@@ -765,6 +766,7 @@ def _cont_feature_dim_combo_changed(self):
 
     def eventFilter(self, obj, event):
         if obj is self.view.viewport() and event.type() == QEvent.Resize:
+            self.repaint = True
             values = [item.dot.value for item in self.feature_items]
             self.feature_marker_values = self.scale_back(values)
             self.update_scene()
@@ -877,6 +879,8 @@ def calculate_log_reg_coefficients(self):
                 self.log_reg_cont_data_extremes.append([None])
 
     def update_scene(self):
+        if not self.repaint:
+            return
         self.clear_scene()
         if self.domain is None or not len(self.points[0]):
             return


Test patch:
diff --git a/Orange/widgets/visualize/tests/test_ownomogram.py b/Orange/widgets/visualize/tests/test_ownomogram.py
--- a/Orange/widgets/visualize/tests/test_ownomogram.py
+++ b/Orange/widgets/visualize/tests/test_ownomogram.py
@@ -24,6 +24,7 @@ def setUpClass(cls):
 
     def setUp(self):
         self.widget = self.create_widget(OWNomogram)
+        self.widget.repaint = True
 
     def test_input_nb_cls(self):
         """Check naive bayes classifier on input"""
Repository: biolab/orange3

Issue:
Silhouette Plot: elide hover labels if labels longer than n characters
<!--
This is an issue template. Please fill in the relevant details in the
sections below.
-->

##### Orange version
<!-- From menu _Help→About→Version_ or code `Orange.version.full_version` -->
3.5.dev

##### Expected behavior
Labels are legible.


##### Actual behavior
Labels, especially if coming from Corpus, extend across the entire screen.


##### Steps to reproduce the behavior
Corpus - Silhouette Plot. Hover on the plot.


##### Additional info (worksheets, data, screenshots, ...)
Labels should be truncated to a sensible length.




Discussion:

Resolving patch:
diff --git a/Orange/widgets/visualize/owsilhouetteplot.py b/Orange/widgets/visualize/owsilhouetteplot.py
--- a/Orange/widgets/visualize/owsilhouetteplot.py
+++ b/Orange/widgets/visualize/owsilhouetteplot.py
@@ -35,6 +35,9 @@
 from Orange.widgets.widget import Msg
 
 
+ROW_NAMES_WIDTH = 200
+
+
 class OWSilhouettePlot(widget.OWWidget):
     name = "Silhouette Plot"
     description = "Visually assess cluster quality and " \
@@ -507,7 +510,10 @@ def setRowNames(self, names):
             item = layout.itemAt(i + 1, 3)
 
             if grp.rownames is not None:
-                item.setItems(grp.rownames)
+                metrics = QFontMetrics(self.font())
+                rownames = [metrics.elidedText(rowname, Qt.ElideRight, ROW_NAMES_WIDTH)
+                            for rowname in grp.rownames]
+                item.setItems(rownames)
                 item.setVisible(self.__rowNamesVisible)
             else:
                 item.setItems([])
@@ -907,8 +913,7 @@ def event(self, event):
         return super().event(event)
 
     def sizeHint(self, which, constraint=QSizeF()):
-        spacing = max(self.__spacing * (self.count() - 1), 0)
-        return QSizeF(300, self.__barsize * self.count() + spacing)
+        return QSizeF(300, (self.__barsize + self.__spacing) * self.count())
 
     def setPreferredBarSize(self, size):
         if self.__barsize != size:
@@ -918,11 +923,6 @@ def setPreferredBarSize(self, size):
     def spacing(self):
         return self.__spacing
 
-    def setSpacing(self, spacing):
-        if self.__spacing != spacing:
-            self.__spacing = spacing
-            self.updateGeometry()
-
     def setPen(self, pen):
         pen = QPen(pen)
         if self.__pen != pen:


Test patch:
Repository: biolab/orange3

Issue:
Remove Nans from Sparse Data
<!--
This is an issue template. Please fill in the relevant details in the
sections below.
-->

##### Orange version
<!-- From menu _Help→About→Version_ or code `Orange.version.full_version` -->
3.5.dev

##### Expected behavior

Logistic Regression works on sparse data that contains nan values.

##### Actual behavior
It crashes with `Input contains Nans, ...`


##### Steps to reproduce the behavior
Load `Election-2016-Tweets.tab` in Corpus. Use just first 100 rows for speed. Pass corpus through bag of words into test & score and use 10-fold cross validation. Add logistic regression on input and test & score crashes.


##### Additional info (worksheets, data, screenshots, ...)





Discussion:

Resolving patch:
diff --git a/Orange/preprocess/impute.py b/Orange/preprocess/impute.py
--- a/Orange/preprocess/impute.py
+++ b/Orange/preprocess/impute.py
@@ -4,7 +4,7 @@
 import Orange.data
 from Orange.statistics import distribution, basic_stats
 from Orange.util import Reprable
-from .transformation import Transformation, Lookup
+from .transformation import Transformation, Lookup as BaseLookup
 
 __all__ = ["ReplaceUnknowns", "Average", "DoNotImpute", "DropInstances",
            "Model", "AsValue", "Random", "Default"]
@@ -26,7 +26,8 @@ def __init__(self, variable, value=0):
         self.value = value
 
     def transform(self, c):
-        if issparse(c):     # sparse does not have unknown values
+        if issparse(c):
+            c.data = numpy.where(numpy.isnan(c.data), self.value, c.data)
             return c
         else:
             return numpy.where(numpy.isnan(c), self.value, c)
@@ -226,7 +227,7 @@ def transform(self, c):
         return ~numpy.isnan(c)
 
 
-class Lookup(Lookup):
+class Lookup(BaseLookup):
     def __init__(self, variable, lookup_table, unknown=None):
         super().__init__(variable, lookup_table)
         self.unknown = unknown


Test patch:
diff --git a/Orange/tests/test_impute.py b/Orange/tests/test_impute.py
--- a/Orange/tests/test_impute.py
+++ b/Orange/tests/test_impute.py
@@ -28,7 +28,19 @@ def test_replacement(self):
     def test_sparse(self):
         m = sp.csr_matrix(np.eye(10))
         rm = preprocess.ReplaceUnknowns(None, value=42).transform(m)
-        self.assertEqual((m!=rm).nnz, 0)
+        self.assertEqual((m != rm).nnz, 0)
+
+    def test_sparse_nans(self):
+        """
+        Remove nans from sparse matrix.
+        GH-2295
+        GH-2178
+        """
+        m = sp.csr_matrix(np.ones((3, 3)))
+        m[0, :] = np.nan
+        self.assertTrue(np.isnan(m.data).any())
+        preprocess.ReplaceUnknowns(None, value=42.).transform(m)
+        self.assertFalse(np.isnan(m.data).any())
 
 
 class TestDropInstances(unittest.TestCase):
Repository: biolab/orange3

Issue:
Paint Data should work on sparse
<!--
This is an issue template. Please fill in the relevant details in the
sections below.
-->

##### Orange version
<!-- From menu _Help→About→Version_ or code `Orange.version.full_version` -->
3.5.dev

##### Expected behavior
Paint Data works on sparse (at least doesn't fail).


##### Actual behavior
Paint Data fails on sparse.


##### Steps to reproduce the behavior
Corpus - Bag of Words - Paint Data.


##### Additional info (worksheets, data, screenshots, ...)





Discussion:
I think 'doesn't fail' could suffice here. Or do you have a reasonable example of sparse data for Paint?
Couldn't think of any, really. Left it open for interpretation intentionally (perhaps for someone with a wilder imagination).
But in essence, yes, **should not fail on sparse**.

Resolving patch:
diff --git a/Orange/widgets/data/owpaintdata.py b/Orange/widgets/data/owpaintdata.py
--- a/Orange/widgets/data/owpaintdata.py
+++ b/Orange/widgets/data/owpaintdata.py
@@ -765,6 +765,7 @@ class OWPaintData(OWWidget):
     class Warning(OWWidget.Warning):
         no_input_variables = Msg("Input data has no variables")
         continuous_target = Msg("Continuous target value can not be used.")
+        sparse_not_supported = Msg("Sparse data is ignored.")
 
     class Information(OWWidget.Information):
         use_first_two = \
@@ -973,6 +974,9 @@ def set_data(self, data):
         """Set the input_data and call reset_to_input"""
         def _check_and_set_data(data):
             self.clear_messages()
+            if data and data.is_sparse():
+                self.Warning.sparse_not_supported()
+                return False
             if data is not None and len(data):
                 if not data.domain.attributes:
                     self.Warning.no_input_variables()


Test patch:
diff --git a/Orange/widgets/data/tests/test_owpaintdata.py b/Orange/widgets/data/tests/test_owpaintdata.py
--- a/Orange/widgets/data/tests/test_owpaintdata.py
+++ b/Orange/widgets/data/tests/test_owpaintdata.py
@@ -2,6 +2,8 @@
 # pylint: disable=missing-docstring, protected-access
 
 import numpy as np
+import scipy.sparse as sp
+
 from AnyQt.QtCore import QRectF, QPointF
 
 from Orange.data import Table, DiscreteVariable, ContinuousVariable, Domain
@@ -56,3 +58,16 @@ def test_20_values_class(self):
         )
         data = Table(domain, [[0.1, 0.2, "a"], [0.4, 0.7, "t"]])
         self.send_signal("Data", data)
+
+    def test_sparse_data(self):
+        """
+        Show warning msg when data is sparse.
+        GH-2298
+        GH-2163
+        """
+        data = Table("iris")[::25]
+        data.X = sp.csr_matrix(data.X)
+        self.send_signal("Data", data)
+        self.assertTrue(self.widget.Warning.sparse_not_supported.is_shown())
+        self.send_signal("Data", None)
+        self.assertFalse(self.widget.Warning.sparse_not_supported.is_shown())