Skip to content

Commit 70e9330

Browse files
OwPythagorasTree: Remove dead code
1 parent 09a722e commit 70e9330

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

Orange/widgets/visualize/owpythagorastree.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def __init__(self):
7575
super().__init__()
7676
# Instance variables
7777
self.model = None
78-
self.instances = None
79-
self.clf_dataset = None
78+
self.data = None
8079
# The tree adapter instance which is passed from the outside
8180
self.tree_adapter = None
8281
self.legend = None
@@ -149,18 +148,12 @@ def __init__(self):
149148
@Inputs.tree
150149
def set_tree(self, model=None):
151150
"""When a different tree is given."""
151+
self.closeContext()
152152
self.clear()
153153
self.model = model
154154

155155
if model is not None:
156-
self.instances = model.instances
157-
# this bit is important for the regression classifier
158-
if self.instances is not None and \
159-
self.instances.domain != model.domain:
160-
self.clf_dataset = self.instances.transform(self.model.domain)
161-
else:
162-
self.clf_dataset = self.instances
163-
156+
self.data = model.instances
164157
self.tree_adapter = self._get_tree_adapter(self.model)
165158
self.ptree.clear()
166159

@@ -203,8 +196,7 @@ def set_tree(self, model=None):
203196
def clear(self):
204197
"""Clear all relevant data from the widget."""
205198
self.model = None
206-
self.instances = None
207-
self.clf_dataset = None
199+
self.data = None
208200
self.tree_adapter = None
209201

210202
if self.legend is not None:
@@ -311,16 +303,21 @@ def onDeleteWidget(self):
311303

312304
def commit(self):
313305
"""Commit the selected data to output."""
314-
if self.instances is None:
306+
if self.data is None:
315307
self.Outputs.selected_data.send(None)
316308
self.Outputs.annotated_data.send(None)
317309
return
318-
nodes = [i.tree_node.label for i in self.scene.selectedItems()
319-
if isinstance(i, SquareGraphicsItem)]
310+
311+
nodes = [
312+
i.tree_node.label for i in self.scene.selectedItems()
313+
if isinstance(i, SquareGraphicsItem)
314+
]
320315
data = self.tree_adapter.get_instances_in_nodes(nodes)
321316
self.Outputs.selected_data.send(data)
322317
selected_indices = self.tree_adapter.get_indices(nodes)
323-
self.Outputs.annotated_data.send(create_annotated_table(self.instances, selected_indices))
318+
self.Outputs.annotated_data.send(
319+
create_annotated_table(self.data, selected_indices)
320+
)
324321

325322
def send_report(self):
326323
"""Send report."""
@@ -331,9 +328,9 @@ def _update_target_class_combo(self):
331328
label = [x for x in self.target_class_combo.parent().children()
332329
if isinstance(x, QLabel)][0]
333330

334-
if self.instances.domain.has_discrete_class:
331+
if self.data.domain.has_discrete_class:
335332
label_text = 'Target class'
336-
values = [c.title() for c in self.instances.domain.class_vars[0].values]
333+
values = [c.title() for c in self.data.domain.class_vars[0].values]
337334
values.insert(0, 'None')
338335
else:
339336
label_text = 'Node color'
@@ -346,7 +343,7 @@ def _update_legend_colors(self):
346343
if self.legend is not None:
347344
self.scene.removeItem(self.legend)
348345

349-
if self.instances.domain.has_discrete_class:
346+
if self.data.domain.has_discrete_class:
350347
self._classification_update_legend_colors()
351348
else:
352349
self._regression_update_legend_colors()
@@ -379,14 +376,14 @@ def _get_colors_domain(domain):
379376

380377
# The colors are the class mean
381378
if self.target_class_index == 1:
382-
values = (np.min(self.clf_dataset.Y), np.max(self.clf_dataset.Y))
379+
values = (np.min(self.data.Y), np.max(self.data.Y))
383380
colors = _get_colors_domain(self.model.domain)
384381
while len(values) != len(colors):
385382
values.insert(1, -1)
386383
items = list(zip(values, colors))
387384
# Colors are the stddev
388385
elif self.target_class_index == 2:
389-
values = (0, np.std(self.clf_dataset.Y))
386+
values = (0, np.std(self.data.Y))
390387
colors = _get_colors_domain(self.model.domain)
391388
while len(values) != len(colors):
392389
values.insert(1, -1)

0 commit comments

Comments
 (0)