Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Orange/widgets/visualize/owruleviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,19 @@ def commit(self):
data_output = None
self._save_selected(actual=True)

data = self.data or self.classifier and self.classifier.instances
if (self.selected is not None and
self.data is not None and
data is not None and
self.classifier is not None and
self.data.domain.attributes ==
data.domain.attributes ==
self.classifier.original_domain.attributes):

status = np.ones(self.data.X.shape[0], dtype=bool)
status = np.ones(data.X.shape[0], dtype=bool)
for i in self.selected:
rule = self.classifier.rule_list[i]
status &= rule.evaluate_data(self.data.X)
status &= rule.evaluate_data(data.X)

data_output = self.data.from_table_rows(
self.data, status.nonzero()[0])
data_output = data.from_table_rows(data, status.nonzero()[0])

self.send(OWRuleViewer.data_output_identifier, data_output)

Expand Down
3 changes: 3 additions & 0 deletions Orange/widgets/visualize/tests/test_owruleviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def setUp(self):
self.titanic = Table('titanic')
self.learner = CN2Learner()
self.classifier = self.learner(self.titanic)
# CN2Learner does not add `instances` attribute to the model, but
# the Rules widget does. We simulate the model we get from the widget.
self.classifier.instances = self.titanic
self.widget = self.create_widget(OWRuleViewer)

def test_set_data(self):
Expand Down