Repository: biolab/orange3

Issue:
Scatter plot missing value rows are selected
**Describe the bug**
For some subsets of selected data in scatterplot, the output `Selected` column is `Yes` for data with missing values. 

**To Reproduce**
File (brown-selected.tab) -> Scatter Plot (select subset, set Data as output) -> Data Table (sort by alpha 7 to see missing values). If it doesn't work at first, then try some other selection in scatterplot.

**Orange version:**
master

**Expected behavior**
Rows with missing values are not shown so they shouldn't be selected.

**Operating system:**
Ubuntu 18.04



Discussion:
The issue is probably in create_annotated_table, it seems to permute the values.

Resolving patch:
diff --git a/Orange/widgets/visualize/utils/widget.py b/Orange/widgets/visualize/utils/widget.py
--- a/Orange/widgets/visualize/utils/widget.py
+++ b/Orange/widgets/visualize/utils/widget.py
@@ -573,7 +573,7 @@ def send_data(self):
         self.output_changed.emit(selected)
         self.Outputs.selected_data.send(selected)
         self.Outputs.annotated_data.send(
-            self._get_annotated_data(data, graph.get_selection(), group_sel,
+            self._get_annotated_data(data, group_sel,
                                      graph.selection))
 
     def _get_projection_data(self):
@@ -597,11 +597,11 @@ def _get_selected_data(data, selection, group_sel):
             if len(selection) else None
 
     @staticmethod
-    def _get_annotated_data(data, selection, group_sel, graph_sel):
+    def _get_annotated_data(data, group_sel, graph_sel):
         if graph_sel is not None and np.max(graph_sel) > 1:
             return create_groups_table(data, group_sel)
         else:
-            return create_annotated_table(data, selection)
+            return create_annotated_table(data, np.nonzero(group_sel)[0])
 
     # Report
     def send_report(self):


Test patch:
diff --git a/Orange/widgets/visualize/tests/test_owprojectionwidget.py b/Orange/widgets/visualize/tests/test_owprojectionwidget.py
--- a/Orange/widgets/visualize/tests/test_owprojectionwidget.py
+++ b/Orange/widgets/visualize/tests/test_owprojectionwidget.py
@@ -126,9 +126,9 @@ def get_embedding(self):
             return None
 
         x_data[x_data == np.inf] = np.nan
-        x_data = np.nanmean(x_data[self.valid_data], 1)
+        x_data_ = np.ones(len(x_data))
         y_data = np.ones(len(x_data))
-        return np.vstack((x_data, y_data)).T
+        return np.vstack((x_data_, y_data)).T
 
 
 class TestOWDataProjectionWidget(WidgetTest, ProjectionWidgetTestMixin,
@@ -145,6 +145,15 @@ def setUpClass(cls):
     def setUp(self):
         self.widget = self.create_widget(TestableDataProjectionWidget)
 
+    def test_annotation_with_nans(self):
+        data = Table.from_table_rows(self.data, [0, 1, 2])
+        data.X[1, :] = np.nan
+        self.send_signal(self.widget.Inputs.data, data)
+        points = self.widget.graph.scatterplot_item.points()
+        self.widget.graph.select_by_click(None, [points[1]])
+        annotated = self.get_output(self.widget.Outputs.annotated_data)
+        np.testing.assert_equal(annotated.get_column_view('Selected')[0], np.array([0, 0, 1]))
+
     def test_saved_selection(self):
         self.send_signal(self.widget.Inputs.data, self.data)
         self.widget.graph.select_by_indices(list(range(0, len(self.data), 10)))