diff --git a/Orange/widgets/visualize/tests/test_owprojectionwidget.py b/Orange/widgets/visualize/tests/test_owprojectionwidget.py index 1b65585bad2..5d74c32d106 100644 --- 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))) diff --git a/Orange/widgets/visualize/utils/widget.py b/Orange/widgets/visualize/utils/widget.py index cdab4dc9761..2fb1762c8cf 100644 --- a/Orange/widgets/visualize/utils/widget.py +++ b/Orange/widgets/visualize/utils/widget.py @@ -601,7 +601,7 @@ def _get_annotated_data(data, selection, 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):