Repository: biolab/orange3

Issue:
Name dataset for Venn Diagram 
Naming a dataset is essential for Venn Diagram (otherwise identity of each displayed dataset can be determined only by checking the number of rows). However, datasets are currently named only on data import into the Orange. If two (or more) Select Rows are done on the same dataset they are named equally and can not be distinguished in Venn  Diagram. One of the widgets (e.g. Edit Domain) should enable renaming of individual data streams. Thus every data passing through it would have the same name (so that the name would be retained after changing the Select Rows filtering).
Related to #1083. 


Discussion:
On a weekly meeting, we agreed to put this into Edit Domain widget.

Resolving patch:
diff --git a/Orange/widgets/data/oweditdomain.py b/Orange/widgets/data/oweditdomain.py
--- a/Orange/widgets/data/oweditdomain.py
+++ b/Orange/widgets/data/oweditdomain.py
@@ -1770,6 +1770,7 @@ class Error(widget.OWWidget.Error):
     _domain_change_store = settings.ContextSetting({})
     _selected_item = settings.ContextSetting(None)  # type: Optional[Tuple[str, int]]
     _merge_dialog_settings = settings.ContextSetting({})
+    output_table_name = settings.ContextSetting("")
 
     want_control_area = False
 
@@ -1809,6 +1810,10 @@ def __init__(self):
 
         box.layout().addWidget(self._editor)
 
+        self.le_output_name = gui.lineEdit(
+            self.mainArea, self, "output_table_name", "Output table name: ",
+            box=True, orientation=Qt.Horizontal)
+
         bbox = QDialogButtonBox()
         bbox.setStyleSheet(
             "button-layout: {:d};".format(QDialogButtonBox.MacLayout))
@@ -1856,10 +1861,12 @@ def set_data(self, data):
             self.info.set_input_summary(len(data),
                                         format_summary_details(data))
             self.setup_model(data)
+            self.le_output_name.setPlaceholderText(data.name)
             self.openContext(self.data)
             self._editor.set_merge_context(self._merge_dialog_settings)
             self._restore()
         else:
+            self.le_output_name.setPlaceholderText("")
             self.info.set_input_summary(self.info.NoInput)
 
         self.commit()
@@ -2054,7 +2061,8 @@ def state(i):
                     model.data(midx, TransformRole))
 
         state = [state(i) for i in range(model.rowCount())]
-        if all(tr is None or not tr for _, tr in state):
+        if all(tr is None or not tr for _, tr in state) \
+                and self.output_table_name in ("", data.name):
             self.Outputs.data.send(data)
             self.info.set_output_summary(len(data),
                                          format_summary_details(data))
@@ -2090,6 +2098,8 @@ def state(i):
         Ys = [v for v in Ys if v.is_primitive()]
         domain = Orange.data.Domain(Xs, Ys, Ms)
         new_data = data.transform(domain)
+        if self.output_table_name:
+            new_data.name = self.output_table_name
         self.Outputs.data.send(new_data)
         self.info.set_output_summary(len(new_data),
                                      format_summary_details(new_data))


Test patch:
diff --git a/Orange/widgets/data/tests/test_oweditdomain.py b/Orange/widgets/data/tests/test_oweditdomain.py
--- a/Orange/widgets/data/tests/test_oweditdomain.py
+++ b/Orange/widgets/data/tests/test_oweditdomain.py
@@ -171,6 +171,11 @@ def test_output_data(self):
         np.testing.assert_array_equal(output.Y, self.iris.Y)
         self.assertEqual(output.domain, self.iris.domain)
 
+        self.widget.output_table_name = "Iris 2"
+        self.widget.commit()
+        output = self.get_output(self.widget.Outputs.data)
+        self.assertEqual(output.name, "Iris 2")
+
     def test_input_from_owcolor(self):
         """Check widget's data sent from OWColor widget"""
         owcolor = self.create_widget(OWColor)