Skip to content

Commit

Permalink
Merge pull request #5837 from VesnaT/scatterplot_attrs_invalidated
Browse files Browse the repository at this point in the history
[FIX] Scatter Plot: Replot when input features change
  • Loading branch information
janezd authored Feb 23, 2022
2 parents ba151c8 + 589345f commit 05fc0df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Orange/widgets/visualize/owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def __init__(self):
self.vizrank: ScatterPlotVizRank = None
self.vizrank_button: QPushButton = None
self.sampling: QGroupBox = None
self._xy_invalidated: bool = True

self.sql_data = None # Orange.data.sql.table.SqlTable
self.attribute_selection_list = None # list of Orange.data.Variable
Expand Down Expand Up @@ -576,6 +577,8 @@ def handleNewSignals(self):
self.attr_x, self.attr_y = self.attribute_selection_list[:2]
self.attr_box.setEnabled(False)
self.vizrank.setEnabled(False)
self._invalidated = self._invalidated or self._xy_invalidated
self._xy_invalidated = False
super().handleNewSignals()
if self._domain_invalidated:
self.graph.update_axes()
Expand All @@ -586,7 +589,7 @@ def handleNewSignals(self):
def set_shown_attributes(self, attributes):
if attributes and len(attributes) >= 2:
self.attribute_selection_list = attributes[:2]
self._invalidated = self._invalidated \
self._xy_invalidated = self._xy_invalidated \
or self.attr_x != attributes[0] \
or self.attr_y != attributes[1]
else:
Expand Down
7 changes: 7 additions & 0 deletions Orange/widgets/visualize/tests/test_owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,13 @@ def test_invalidated_same_time_features_first(self):
self.widget.setup_plot.assert_called_once()
self.assertListEqual(self.widget.effective_variables, list(features))

self.widget.setup_plot.reset_mock()
features = self.data.domain.attributes[2:]
signals = [(self.widget.Inputs.features, AttributeList(features)),
(self.widget.Inputs.data, self.data)]
self.send_signals(signals)
self.widget.setup_plot.assert_called_once()

def test_invalidated_diff_features(self):
self.widget.setup_plot = Mock()
# send data and set default features
Expand Down

0 comments on commit 05fc0df

Please sign in to comment.