Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrejaKovacic committed Dec 21, 2018
1 parent 7c5c4fc commit c3f0760
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Orange/widgets/data/owmergedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,14 @@ def _join_table_by_indices(self, reduced_extra, indices):
X = self._join_array_by_indices(self.data.X, reduced_extra.X, indices)
Y = self._join_array_by_indices(
np.c_[self.data.Y], np.c_[reduced_extra.Y], indices)
string_cols = [i for i, var in enumerate(self.data.domain.metas) if var.is_string]
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)
table = Orange.data.Table.from_numpy(domain, X, Y, metas)
table.name = getattr(self.data, 'name')
table.attributes = getattr(self.data, 'attributes')
table.ids = getattr(self.data, 'ids')
return Orange.data.Table.from_numpy(domain, X, Y, metas)
return table

@staticmethod
def _join_array_by_indices(left, right, indices, string_cols=None):
Expand Down
9 changes: 7 additions & 2 deletions 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 @@ -233,8 +237,9 @@ def test_output_merge_by_attribute_left(self):
self.widget.commit()
output = self.get_output(self.widget.Outputs.data)
self.assertTablesEqual(output, result)
self.assertNotEqual(id(output), id(self.dataA))
self.assertNotEqual(id(output), id(self.dataB))
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 c3f0760

Please sign in to comment.