Skip to content

Commit

Permalink
Merge pull request biolab#1895 from BlazZupan/add-data-attributes
Browse files Browse the repository at this point in the history
[FIX] Copy data attributes for annotated data set
(cherry picked from commit 097bf2a)
  • Loading branch information
lanzagar authored and astaric committed Jan 18, 2017
1 parent c8d608a commit 932042a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Orange/widgets/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,12 @@ def test_outputs(self):
self.same_input_output_domain)
np.testing.assert_array_equal(selected.X[:, :n_attr],
self.data.X[selected_indices])
self.assertEqual(selected.attributes, self.data.attributes)

# check annotated data output
annotated = self.get_output(ANNOTATED_DATA_SIGNAL_NAME)
self.assertEqual(n_sel, np.sum([i[feature_name] for i in annotated]))
self.assertEqual(annotated.attributes, self.data.attributes)

# compare selected and annotated data domains
self._compare_selected_annotated_domains(selected, annotated)
Expand Down
6 changes: 4 additions & 2 deletions Orange/widgets/utils/annotated_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ def create_annotated_table(data, selected_indices):
annotated = np.zeros((len(data), 1))
if selected_indices is not None:
annotated[selected_indices] = 1
return Table(domain, data.X, data.Y,
metas=np.hstack((data.metas, annotated)))
table = Table(domain, data.X, data.Y,
metas=np.hstack((data.metas, annotated)))
table.attributes = data.attributes
return table

0 comments on commit 932042a

Please sign in to comment.