Skip to content

Commit

Permalink
Fix select annotations, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrejaKovacic committed Feb 3, 2020
1 parent 148959e commit 5c6bda7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions Orange/widgets/visualize/tests/test_owprojectionwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/visualize/utils/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 5c6bda7

Please sign in to comment.