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

Issue:
Alternating shadowing of rows in Rank widget does not shadows the row header
##### Orange version

3.5.dev

##### Expected behavior

Row headers should be shaded as well, else shading every other row does not make sense.

##### Actual behavior

Scores in Rank widget are shaded (every other row), header column appears in another gray color and the color is uniform.


Discussion:

Resolving patch:
diff --git a/Orange/widgets/data/owrank.py b/Orange/widgets/data/owrank.py
--- a/Orange/widgets/data/owrank.py
+++ b/Orange/widgets/data/owrank.py
@@ -73,9 +73,9 @@ def __init__(self, parent=None, **kwargs):
                          selectionBehavior=QTableView.SelectRows,
                          selectionMode=QTableView.ExtendedSelection,
                          sortingEnabled=True,
-                         showGrid=False,
+                         showGrid=True,
                          cornerButtonEnabled=False,
-                         alternatingRowColors=True,
+                         alternatingRowColors=False,
                          **kwargs)
         self.setItemDelegate(gui.ColoredBarItemDelegate(self))
         self.setItemDelegateForColumn(0, QItemDelegate())


Test patch:
Repository: biolab/orange3

Issue:
Scatter Plot: always automatically sends selection
##### Orange version
since 3.3.7 (or maybe since one of previous versions)


##### Expected behavior
Scatter Plot automatically sends selection only when the checkbox **Send automatically** is checked.


##### Actual behavior
It always sends selection.


##### Steps to reproduce the behavior



##### Additional info (worksheets, data, screenshots, ...)
![screenshot_20171003_110437](https://user-images.githubusercontent.com/22157215/31117770-4e1ebae4-a82b-11e7-8f56-7905e3126320.png)





Discussion:

Resolving patch:
diff --git a/Orange/widgets/visualize/owscatterplot.py b/Orange/widgets/visualize/owscatterplot.py
--- a/Orange/widgets/visualize/owscatterplot.py
+++ b/Orange/widgets/visualize/owscatterplot.py
@@ -425,7 +425,7 @@ def update_graph(self, reset_view=True, **_):
         self.graph.update_data(self.attr_x, self.attr_y, reset_view)
 
     def selection_changed(self):
-        self.send_data()
+        self.commit()
 
     def send_data(self):
         selected = None


Test patch:
diff --git a/Orange/widgets/visualize/tests/test_owscatterplot.py b/Orange/widgets/visualize/tests/test_owscatterplot.py
--- a/Orange/widgets/visualize/tests/test_owscatterplot.py
+++ b/Orange/widgets/visualize/tests/test_owscatterplot.py
@@ -339,6 +339,21 @@ def test_vizrank(self):
         states = [state for state in vizrank.iterate_states(None)]
         self.assertIsNotNone(vizrank.compute_score(states[0]))
 
+    def test_auto_send_selection(self):
+        """
+        Scatter Plot automatically sends selection only when the checkbox Send automatically
+        is checked.
+        GH-2649
+        GH-2646
+        """
+        data = Table("iris")
+        self.send_signal(self.widget.Inputs.data, data)
+        self.widget.controls.auto_send_selection.setChecked(False)
+        self.assertEqual(False, self.widget.controls.auto_send_selection.isChecked())
+        self._select_data()
+        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))
+        self.widget.controls.auto_send_selection.setChecked(True)
+        self.assertIsInstance(self.get_output(self.widget.Outputs.selected_data), Table)
 
 
 if __name__ == "__main__":
Repository: biolab/orange3

Issue:
boxplot: Hide labels
Boxplot should include an option that can be used to not show the label.

Reasoning:
<img width="521" alt="screen shot 2017-10-05 at 00 05 09" src="https://user-images.githubusercontent.com/588601/31202016-250d4134-a961-11e7-8b7b-1a1e2381f292.png">
 



Discussion:

Resolving patch:
diff --git a/Orange/widgets/visualize/owboxplot.py b/Orange/widgets/visualize/owboxplot.py
--- a/Orange/widgets/visualize/owboxplot.py
+++ b/Orange/widgets/visualize/owboxplot.py
@@ -139,6 +139,7 @@ class Outputs:
     stattest = Setting(0)
     sig_threshold = Setting(0.05)
     stretched = Setting(True)
+    show_labels = Setting(True)
     auto_commit = Setting(True)
 
     _sorting_criteria_attrs = {
@@ -226,10 +227,15 @@ def __init__(self):
             callback=self.layout_changed)
 
         # The vertical size policy is needed to let only the list views expand
-        self.stretching_box = gui.checkBox(
-            self.controlArea, self, 'stretched', "Stretch bars", box='Display',
-            callback=self.display_changed,
-            sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Maximum)).box
+        self.stretching_box = box = gui.vBox(
+            self.controlArea, box="Display",
+            sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Maximum))
+        gui.checkBox(
+            box, self, 'stretched', "Stretch bars",
+            callback=self.display_changed)
+        gui.checkBox(
+            box, self, 'show_labels', "Show box labels",
+            callback=self.display_changed)
 
         gui.auto_commit(self.controlArea, self, "auto_commit",
                         "Send Selection", "Send Automatically")
@@ -544,7 +550,7 @@ def display_changed_disc(self):
                 label.setPos(right + 10, y - b.height() / 2)
                 self.box_scene.addItem(label)
 
-            if self.attribute is not self.group_var:
+            if self.show_labels and self.attribute is not self.group_var:
                 for text_item, bar_part in zip(box[1::2], box[::2]):
                     label = QGraphicsSimpleTextItem(
                         text_item.toPlainText())


Test patch:
Repository: biolab/orange3

Issue:
Scatterplots reports wrong r
##### Orange version

3.6.0

##### Expected behavior

Instead of the slope, Scatt Plot should display R^2, a [statistical measure](https://en.wikipedia.org/wiki/Coefficient_of_determination) of how close the data are to the fitted regression line.

##### Actual behavior

Scatter Plot displays the slope of the line.

<img width="1034" alt="scatterplot-r-fail" src="https://user-images.githubusercontent.com/726604/31826610-cdd09180-b5b5-11e7-93c9-64e77b53c292.png">

##### Steps to reproduce the behavior

Use Scatter Plot on the data from the following data file:

[scatterplot-r-fail.tab.zip](https://github.com/biolab/orange3/files/1402324/scatterplot-r-fail.tab.zip)


Discussion:
> Best-fit values	 
> Slope	0.02325 ± 0.001349
> Y-intercept	0.4201 ± 0.1362
> X-intercept	-18.07
> 1/Slope	43.00
>  
> 95% Confidence Intervals	 
> Slope	0.02055 to 0.02596
> Y-intercept	0.1469 to 0.6933
> X-intercept	-33.39 to -5.718
>  
> Goodness of Fit	 
> R square	0.8438
> Sy.x	0.4563
>  
> Is slope significantly non-zero?	 
> F	297.0
> DFn,DFd	1,55
> P Value	< 0.0001
> Deviation from horizontal?	Significant
>  
> Data	 
> Number of XY pairs	57
> Equation	Y = 0.02325*X + 0.4201
> 

Resolving patch:
diff --git a/Orange/widgets/visualize/owscatterplotgraph.py b/Orange/widgets/visualize/owscatterplotgraph.py
--- a/Orange/widgets/visualize/owscatterplotgraph.py
+++ b/Orange/widgets/visualize/owscatterplotgraph.py
@@ -750,7 +750,7 @@ def update_data(self, attr_x, attr_y, reset_view=True):
 
     def draw_regression_line(self, x_data, y_data, min_x, max_x):
         if self.show_reg_line and self.can_draw_regresssion_line():
-            slope, intercept, _, _, _ = linregress(x_data, y_data)
+            slope, intercept, rvalue, _, _ = linregress(x_data, y_data)
             start_y = min_x * slope + intercept
             end_y = max_x * slope + intercept
             angle = np.degrees(np.arctan((end_y - start_y) / (max_x - min_x)))
@@ -760,7 +760,7 @@ def draw_regression_line(self, x_data, y_data, min_x, max_x):
                           rotateAxis=(1, 0), movable=True)
             self.reg_line_item = InfiniteLine(
                 pos=QPointF(min_x, start_y), pen=pg.mkPen(color=color, width=1),
-                angle=angle, label="r = {:.2f}".format(slope), labelOpts=l_opts)
+                angle=angle, label="r = {:.2f}".format(rvalue), labelOpts=l_opts)
             if rotate:
                 self.reg_line_item.label.angle = 180
                 self.reg_line_item.label.updateTransform()


Test patch:
Repository: biolab/orange3

Issue:
Tree Viewer: reset view upon changing parameters
##### Orange version
<!-- From menu _Help→About→Version_ or code `Orange.version.full_version` -->
3.7.dev

##### Expected behavior
Changing parameters in visualization resets the view to top left (where the visualization is).

##### Actual behavior
Window stays at current place, making the visualization disappear from view and the user needs to scroll around to find it.

##### Steps to reproduce the behavior
File (perhaps with housing, since it's big) - Tree - Tree Viewer. Scroll to bottom right, then set the parameter Depth to 3 levels. You lose the visualization.

##### Additional info (worksheets, data, screenshots, ...)
No changes:
<img width="869" alt="screen shot 2017-10-23 at 14 58 02" src="https://user-images.githubusercontent.com/12524972/31890252-c0c42bc4-b802-11e7-9fa4-271f2fedb5aa.png">

With depth limited to 3:
<img width="869" alt="screen shot 2017-10-23 at 14 57 53" src="https://user-images.githubusercontent.com/12524972/31890280-d651d324-b802-11e7-817b-d7afe54e003a.png">





Discussion:

Resolving patch:
diff --git a/Orange/widgets/visualize/owtreeviewer2d.py b/Orange/widgets/visualize/owtreeviewer2d.py
--- a/Orange/widgets/visualize/owtreeviewer2d.py
+++ b/Orange/widgets/visualize/owtreeviewer2d.py
@@ -275,8 +275,7 @@ def fix_pos(self, node=None, x=10, y=10):
         if not x or not y:
             x, y = self._HSPACING, self._VSPACING
         self._fix_pos(node, x, y)
-        rect = self.itemsBoundingRect().adjusted(-10, -10, 20, 20)
-        self.setSceneRect(rect)
+        self.setSceneRect(QRectF(0, 0, self.gx, self.gy).adjusted(-10, -10, 100, 100))
         self.update()
 
     def _fix_pos(self, node, x, y):
@@ -464,13 +463,14 @@ def toggle_line_width(self):
         tree_adapter = self.root_node.tree_adapter
         root_instances = tree_adapter.num_samples(self.root_node.node_inst)
         width = 3
+        OFFSET = 0.20
         for edge in self.scene.edges():
             num_inst = tree_adapter.num_samples(edge.node2.node_inst)
             if self.line_width_method == 1:
-                width = 8 * num_inst / root_instances
+                width = 8 * num_inst / root_instances + OFFSET
             elif self.line_width_method == 2:
                 width = 8 * num_inst / tree_adapter.num_samples(
-                    edge.node1.node_inst)
+                    edge.node1.node_inst) + OFFSET
             edge.setPen(QPen(Qt.gray, width, Qt.SolidLine, Qt.RoundCap))
         self.scene.update()
 


Test patch:
Repository: biolab/orange3

Issue:
OWDistributions: Legend layout
Legend items in the distribution widget have too much vertical spacing and cover entire plot when labels are long.

##### Orange version
3.5.0.dev0+fce22ac (master)

##### Expected behavior
The problem doesn't always occur, the vertical spacing seems dependent on the label length (different groupings for the adult dataset).
![](https://i.gyazo.com/57fcf3cccaa6b4a148b10b8a376caec1.png)

##### Actual behavior
Legend items have large vertical spacing and cover the entire plot when labels are long. Perhaps introduce text wrapping for long labels?
![](https://i.gyazo.com/af3fbf66f1875bc2a75d42071a227e05.png)


##### Steps to reproduce the behavior
File (cyber-security-breaches) → Distributions (select arbitrary group by variable)






Discussion:

Resolving patch:
diff --git a/Orange/widgets/visualize/owscatterplotgraph.py b/Orange/widgets/visualize/owscatterplotgraph.py
--- a/Orange/widgets/visualize/owscatterplotgraph.py
+++ b/Orange/widgets/visualize/owscatterplotgraph.py
@@ -83,7 +83,6 @@ def __init__(self, size=None, offset=None, pen=None, brush=None):
         super().__init__(size, offset)
 
         self.layout.setContentsMargins(5, 5, 5, 5)
-        self.layout.setVerticalSpacing(0)
         self.layout.setHorizontalSpacing(15)
         self.layout.setColumnAlignment(1, Qt.AlignLeft | Qt.AlignVCenter)
 


Test patch:
Repository: biolab/orange3

Issue:
Crash on hovering over many points in ScatterPlot
##### Orange version
3.11

##### Expected behavior
Computer does not crash when I hover over many points in ScatterPlot


##### Actual behavior
Computer crashes


##### Steps to reproduce the behavior
Open attached workflow (you will need to change extension first). Send output from python script, open scatter plot, hover over the point(s).


##### Additional info (worksheets, data, screenshots, ...)
[crash.ows](https://github.com/biolab/orange3/files/1856019/crash.ows.txt)




Discussion:

Resolving patch:
diff --git a/Orange/widgets/visualize/owscatterplotgraph.py b/Orange/widgets/visualize/owscatterplotgraph.py
--- a/Orange/widgets/visualize/owscatterplotgraph.py
+++ b/Orange/widgets/visualize/owscatterplotgraph.py
@@ -36,6 +36,8 @@
 
 SELECTION_WIDTH = 5
 MAX = 11  # maximum number of colors or shapes (including Other)
+MAX_POINTS_IN_TOOLTIP = 5
+
 
 class PaletteItemSample(ItemSample):
     """A color strip to insert into legends for discretized continuous values"""
@@ -1227,8 +1229,16 @@ def point_data(p):
 
         act_pos = self.scatterplot_item.mapFromScene(event.scenePos())
         points = self.scatterplot_item.pointsAt(act_pos)
+
         if len(points):
-            text = "<hr/>".join(point_data(point) for point in points)
+            if len(points) > MAX_POINTS_IN_TOOLTIP:
+                text = "{} instances<hr/>{}<hr/>...".format(
+                    len(points),
+                    "<hr/>".join(point_data(point) for point in points[:MAX_POINTS_IN_TOOLTIP])
+                )
+            else:
+                text = "<hr/>".join(point_data(point) for point in points)
+
             QToolTip.showText(event.screenPos(), text, widget=self.plot_widget)
             return True
         else:


Test patch:
Repository: biolab/orange3

Issue:
cannot install add-ons from the menu
<!--
This is an issue template. Please fill in the relevant details in the
sections below.

Wrap code and verbatim terminal window output into triple backticks, see:
https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code

If you're raising an issue about an add-on (e.g. installed via
Options > Add-ons), raise an issue on the relevant add-on's issue
tracker instead. See: https://github.com/biolab?q=orange3
-->

##### Orange version
Linux last version


##### Expected behavior
getting a list of add-ons using options/add-ons


##### Actual behavior
pop up as follows:
Error encountered:
Traceback (most recent call last):
  File "/home/roudenko/.local/lib/python3.5/site-packages/Orange/canvas/application/canvasmain.py", line 1625, in open_addons
    if not have_install_permissions():
  File "/home/roudenko/.local/lib/python3.5/site-packages/Orange/canvas/application/addons.py", line 755, in have_install_permissions
    with open(fn, "w"):
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.5/site-packages/test_write_19468'



##### Steps to reproduce the behavior
I guess the pb is related to the fact that I installed Orange locally.
Indeed, I do not even have the directory /usr/lib/python3.5/site-packages


##### Additional info (worksheets, data, screenshots, ...)

Is the only way to get add-ons in this case is to install them from your git using pip?







Discussion:
> Is the only way to get add-ons in this case is to install them from your git using pip?

We prefer using Anaconda distribution, where you can install them with conda install orange3-text, for example.
I will have a look at the issue in the meantime.

Resolving patch:
diff --git a/Orange/canvas/application/addons.py b/Orange/canvas/application/addons.py
--- a/Orange/canvas/application/addons.py
+++ b/Orange/canvas/application/addons.py
@@ -756,7 +756,7 @@ def have_install_permissions():
             pass
         os.remove(fn)
         return True
-    except PermissionError:
+    except OSError:
         return False
 
 


Test patch:
Repository: biolab/orange3

Issue:
Merge Data: Add autocommit button
When options in Merge Data widget change, they are applied automatically. When dealing with large data, switching merge type and selecting different features to merge applies three times (after each change).

Adding an autocommit would allow the user to make all cahnges and then wait one time for the data to be merged.





Discussion:

Resolving patch:
diff --git a/Orange/widgets/data/owmergedata.py b/Orange/widgets/data/owmergedata.py
--- a/Orange/widgets/data/owmergedata.py
+++ b/Orange/widgets/data/owmergedata.py
@@ -44,6 +44,7 @@ class Outputs:
     attr_combine_data = settings.Setting('', schema_only=True)
     attr_combine_extra = settings.Setting('', schema_only=True)
     merging = settings.Setting(0)
+    auto_apply = settings.Setting(True)
 
     want_main_area = False
     resizing_enabled = False
@@ -111,6 +112,9 @@ def add_option(label, pre_label, between_label,
                    self.model_unique_with_id, self.extra_model_unique_with_id)
         self.set_merging()
 
+        gui.auto_commit(self.controlArea, self, "auto_apply", "&Apply",
+                        box=False)
+
     def set_merging(self):
         # pylint: disable=invalid-sequence-index
         # all boxes should be hidden before one is shown, otherwise widget's


Test patch:
diff --git a/Orange/widgets/data/tests/test_owmergedata.py b/Orange/widgets/data/tests/test_owmergedata.py
--- a/Orange/widgets/data/tests/test_owmergedata.py
+++ b/Orange/widgets/data/tests/test_owmergedata.py
@@ -450,3 +450,17 @@ def test_sparse(self):
 
         output_sparse.X = output_sparse.X.toarray()
         self.assertTablesEqual(output_dense, output_sparse)
+
+    def test_disable_auto_apply(self):
+        """Check if disable auto apply works as expected"""
+        self.widget.auto_apply = False
+        self.send_signal(self.widget.Inputs.data, self.dataA)
+        self.send_signal(self.widget.Inputs.extra_data, self.dataB)
+        self.assertIsNone(self.get_output(self.widget.Outputs.data))
+
+    def test_enable_auto_apply(self):
+        """Check if enable auto apply works as expected"""
+        self.widget.auto_apply = True
+        self.send_signal(self.widget.Inputs.data, self.dataA)
+        self.send_signal(self.widget.Inputs.extra_data, self.dataB)
+        self.assertIsNotNone(self.get_output(self.widget.Outputs.data))
Repository: biolab/orange3

Issue:
owsql: Wrong auto-discovered DiscreteVariable values
##### Orange version
3.14.0 dev

##### Expected behavior
SQL Table correctly discovers categorical variables.

##### Actual behavior
`DiscreteVariable` values for char fields have additional with space on the end.

##### Steps to reproduce the behavior
SQL for Postgres:

``` sql
CREATE TABLE COMPANY(                                                                                                
   ID INT PRIMARY KEY     NOT NULL,
   ADDRESS        CHAR(50)
);
INSERT INTO COMPANY (ID,ADDRESS) VALUES (1, 'California');
```
In SQL Table select tabel company

##### Additional info (worksheets, data, screenshots, ...)
This issue is because on data query `::text` is used that removes the additional white space.


Discussion:

Resolving patch:
diff --git a/Orange/data/sql/backend/postgres.py b/Orange/data/sql/backend/postgres.py
--- a/Orange/data/sql/backend/postgres.py
+++ b/Orange/data/sql/backend/postgres.py
@@ -165,6 +165,8 @@ def _guess_variable(self, field_name, field_metadata, inspect_table):
         if type_code in CHAR_TYPES:
             if inspect_table:
                 values = self.get_distinct_values(field_name, inspect_table)
+                # remove trailing spaces
+                values = [v.rstrip() for v in values]
                 if values:
                     return DiscreteVariable.make(field_name, values)
 


Test patch:
diff --git a/Orange/tests/sql/test_sql_table.py b/Orange/tests/sql/test_sql_table.py
--- a/Orange/tests/sql/test_sql_table.py
+++ b/Orange/tests/sql/test_sql_table.py
@@ -346,6 +346,14 @@ def test_discrete_char(self):
         sql_table = SqlTable(conn, table_name, inspect_values=True)
         self.assertFirstAttrIsInstance(sql_table, DiscreteVariable)
 
+    def test_discrete_bigger_char(self):
+        """Test if the discrete values are the same for bigger char fields"""
+        table = np.array(['M', 'F', 'M', 'F', 'M', 'F']).reshape(-1, 1)
+        conn, table_name = self.create_sql_table(table, ['char(10)'])
+
+        sql_table = SqlTable(conn, table_name, inspect_values=True)
+        self.assertSequenceEqual(sql_table.domain[0].values, ['F', 'M'])
+
     def test_meta_char(self):
         table = np.array(list('ABCDEFGHIJKLMNOPQRSTUVW')).reshape(-1, 1)
         conn, table_name = self.create_sql_table(table, ['char(1)'])
Repository: biolab/orange3

Issue:
K-means: work on sparse
https://github.com/biolab/orange3/blob/1eb9b69d37e35b159bd6892a606606803c537da1/Orange/clustering/kmeans.py#L29

```len(X)``` should be ```X.shape[0]``` beacause it raise error ```sparse matrix length is ambiguous; use getnnz() or shape[0]``` when use tf-idf sparse matrix with Kmeans

Error flow
![error](https://user-images.githubusercontent.com/19968582/36337906-45b179cc-13d4-11e8-8ee9-a499f9666891.PNG)



Discussion:

Resolving patch:
diff --git a/Orange/clustering/kmeans.py b/Orange/clustering/kmeans.py
--- a/Orange/clustering/kmeans.py
+++ b/Orange/clustering/kmeans.py
@@ -27,7 +27,7 @@ def fit(self, X, Y=None):
         proj.silhouette = np.nan
         try:
             if self._compute_silhouette and 2 <= proj.n_clusters < X.shape[0]:
-                if len(X) <= SILHOUETTE_MAX_SAMPLES:
+                if X.shape[0] <= SILHOUETTE_MAX_SAMPLES:
                     proj.silhouette_samples = \
                         silhouette_samples(X, proj.labels_)
                     proj.silhouette = np.mean(proj.silhouette_samples)
@@ -69,4 +69,4 @@ def __call__(self, data):
                 domain,
                 np.atleast_2d(self.proj.predict(data._x.reshape(1, -1))).astype(int))
         else:
-            return self.proj.predict(data).reshape((len(data), 1))
+            return self.proj.predict(data).reshape((data.shape[0], 1))


Test patch:
diff --git a/Orange/tests/test_clustering_kmeans.py b/Orange/tests/test_clustering_kmeans.py
--- a/Orange/tests/test_clustering_kmeans.py
+++ b/Orange/tests/test_clustering_kmeans.py
@@ -2,9 +2,11 @@
 # pylint: disable=missing-docstring
 
 import unittest
+import numpy as np
 
 import Orange
 from Orange.clustering.kmeans import KMeans
+from scipy.sparse import csc_matrix
 
 
 class TestKMeans(unittest.TestCase):
@@ -47,3 +49,16 @@ def test_predict_numpy(self):
         X = self.iris.X[::20]
         p = c(X)
 
+    def test_predict_sparse(self):
+        kmeans = KMeans()
+        c = kmeans(self.iris)
+        X = csc_matrix(self.iris.X[::20])
+        p = c(X)
+
+    def test_silhouette_sparse(self):
+        """Test if silhouette gets calculated for sparse data"""
+        kmeans = KMeans(compute_silhouette_score=True)
+        sparse_iris = self.iris.copy()
+        sparse_iris.X = csc_matrix(sparse_iris.X)
+        c = kmeans(sparse_iris)
+        self.assertFalse(np.isnan(c.silhouette))