Skip to content

Commit

Permalink
OWApplyDomain: introduce self.template_data, remove self.template_domain
Browse files Browse the repository at this point in the history
  • Loading branch information
aturanjanin committed Apr 2, 2020
1 parent 746b97f commit 6a99ac7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
18 changes: 8 additions & 10 deletions Orange/widgets/data/owtransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from AnyQt.QtCore import Qt

from Orange.data import Table, Domain
from Orange.data import Table
from Orange.widgets import gui
from Orange.widgets.report.report import describe_data
from Orange.widgets.utils.sql import check_sql_input
Expand Down Expand Up @@ -36,7 +36,6 @@ def __init__(self):
super().__init__()
self.data = None # type: Optional[Table]
self.template_data = None # type: Optional[Table]
self.template_domain = None # type: Optional[Domain]
self.transformed_info = describe_data(None) # type: OrderedDict

info_box = gui.widgetBox(self.controlArea, "Info")
Expand All @@ -59,11 +58,11 @@ def set_input_label_text(self):

def set_template_label_text(self):
text = "No template data on input."
if self.data and self.template_domain is not None:
if self.data and self.template_data is not None:
text = "Template domain applied."
elif self.template_domain is not None:
elif self.template_data is not None:
text = "Template data includes {:,} features.".format(
len(self.template_domain.attributes))
len(self.template_data.domain.attributes))
self.template_label.setText(text)

def set_output_label_text(self, data):
Expand All @@ -82,7 +81,6 @@ def set_data(self, data):
@Inputs.template_data
@check_sql_input
def set_template_data(self, data):
self.template_domain = data and data.domain
self.template_data = data

def handleNewSignals(self):
Expand All @@ -103,9 +101,9 @@ def handleNewSignals(self):
def apply(self):
self.clear_messages()
transformed_data = None
if self.data and self.template_domain is not None:
if self.data and self.template_data is not None:
try:
transformed_data = self.data.transform(self.template_domain)
transformed_data = self.data.transform(self.template_data.domain)
except Exception as ex: # pylint: disable=broad-except
self.Error.error(ex)

Expand All @@ -121,8 +119,8 @@ def apply(self):
def send_report(self):
if self.data:
self.report_data("Data", self.data)
if self.template_domain is not None:
self.report_domain("Template data", self.template_domain)
if self.template_data is not None:
self.report_domain("Template data", self.template_data.domain)
if self.transformed_info:
self.report_items("Transformed data", self.transformed_info)

Expand Down
1 change: 0 additions & 1 deletion Orange/widgets/data/tests/test_owtransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def test_output(self):
self.assertEqual(info._StateInfo__output_summary.brief, summary)
self.assertEqual(info._StateInfo__output_summary.details, details)


# remove template data
self.send_signal(self.widget.Inputs.template_data, None)
output = self.get_output(self.widget.Outputs.transformed_data)
Expand Down

0 comments on commit 6a99ac7

Please sign in to comment.