Skip to content

Commit

Permalink
Merge pull request #3474 from AndrejaKovacic/fix_metas
Browse files Browse the repository at this point in the history
[FIX] OWMergeData removes table meta attributes
  • Loading branch information
janezd authored Dec 21, 2018
2 parents b0c213f + 383c2aa commit 0f189a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Orange/widgets/data/owmergedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,11 @@ def _join_table_by_indices(self, reduced_extra, indices):
string_cols = [i for i, var in enumerate(domain.metas) if var.is_string]
metas = self._join_array_by_indices(
self.data.metas, reduced_extra.metas, indices, string_cols)
return Orange.data.Table.from_numpy(domain, X, Y, metas)
table = Orange.data.Table.from_numpy(domain, X, Y, metas)
table.name = getattr(self.data, 'name', '')
table.attributes = getattr(self.data, 'attributes', {})
table.ids = self.data.ids
return table

@staticmethod
def _join_array_by_indices(left, right, indices, string_cols=None):
Expand Down
10 changes: 9 additions & 1 deletion Orange/widgets/data/tests/test_owmergedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ def setUpClass(cls):
yB = np.array([np.nan, 1, 0])
metasB = np.array([[np.nan], [1], [0]]).astype(object)
cls.dataA = Table(domainA, XA, yA, metasA)
cls.dataA.name = 'dataA'
cls.dataA.attributes = 'dataA attributes'
cls.dataB = Table(domainB, XB, yB, metasB)
cls.dataB.name = 'dataB'
cls.dataB.attributes = 'dataB attributes'

def setUp(self):
self.widget = self.create_widget(OWMergeData)
Expand Down Expand Up @@ -231,7 +235,11 @@ def test_output_merge_by_attribute_left(self):
self.widget.attr_augment_data = domainA[0]
self.widget.attr_augment_extra = domainB[0]
self.widget.commit()
self.assertTablesEqual(self.get_output(self.widget.Outputs.data), result)
output = self.get_output(self.widget.Outputs.data)
self.assertTablesEqual(output, result)
self.assertEqual(output.name, self.dataA.name)
np.testing.assert_array_equal(output.ids, self.dataA.ids)
self.assertEqual(output.attributes, self.dataA.attributes)

def test_output_merge_by_attribute_inner(self):
"""Check output for merging option 'Find matching rows' by attribute"""
Expand Down

0 comments on commit 0f189a5

Please sign in to comment.