Skip to content

Commit 14d2cf0

Browse files
committed
OWMergeData: Add missing ids for outer join
1 parent 30c9e67 commit 14d2cf0

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Orange/widgets/data/owmergedata.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,9 @@ def best_match(model, extra_model):
305305
if len(state) == 1 \
306306
and not any(isinstance(v, Variable) for v in state[0]):
307307
l_var, r_var = best_match(box.model_left, box.model_right)
308-
self._try_set_combo(box.rows[0].left_combo, l_var)
309-
self._try_set_combo(box.rows[0].right_combo, r_var)
308+
if l_var is not None:
309+
self._try_set_combo(box.rows[0].left_combo, l_var)
310+
self._try_set_combo(box.rows[0].right_combo, r_var)
310311

311312
@Inputs.data
312313
@check_sql_input
@@ -554,7 +555,12 @@ def _join_table_by_indices(self, reduced_extra, lefti, righti):
554555
table = Orange.data.Table.from_numpy(domain, X, Y, metas)
555556
table.name = getattr(self.data, 'name', '')
556557
table.attributes = getattr(self.data, 'attributes', {})
557-
table.ids = self.data.ids
558+
if self.merging == self.OuterJoin:
559+
table.ids = np.hstack(
560+
(self.data.ids,
561+
self.extra_data.ids[righti[len(self.data):]]))
562+
else:
563+
table.ids = self.data.ids[lefti]
558564
return table
559565

560566
@staticmethod

Orange/widgets/data/tests/test_owmergedata.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,9 @@ def test_output_merge_by_ids_outer(self):
457457
self.send_signal(self.widget.Inputs.extra_data, self.dataA[1:, [1, "cls", -2]])
458458
self.widget.attr_boxes.set_state([(INSTANCEID, INSTANCEID)])
459459
self.widget.controls.merging.buttons[self.widget.OuterJoin].click()
460-
self.assertTablesEqual(self.get_output(self.widget.Outputs.data), result)
460+
out = self.get_output(self.widget.Outputs.data)
461+
self.assertTablesEqual(out, result)
462+
np.testing.assert_equal(out.ids, [0, 1, 2, 3])
461463

462464
def test_output_merge_by_index_left(self):
463465
"""Check output for merging option 'Append columns from Extra Data' by

0 commit comments

Comments
 (0)