Skip to content

Commit

Permalink
OWTSNE: Fix failing tests due to context settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlin-policar committed May 6, 2019
1 parent d5fe47e commit f77bad6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Orange/widgets/unsupervised/owtsne.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ def init_attr_values(self):
self.controls.pca_components.setMaximum(max_components)
self.controls.pca_components.setValue(_DEFAULT_PCA_COMPONENTS)

self.exaggeration = 1

def enable_controls(self):
super().enable_controls()

Expand All @@ -433,6 +435,9 @@ def enable_controls(self):
else:
self.normalize_cbx.setToolTip("")

# Disable the perplexity spin box if multiscale is turned on
self.controls.perplexity.setDisabled(self.multiscale)

def run(self):
self._set_modified(False)

Expand Down
12 changes: 10 additions & 2 deletions Orange/widgets/unsupervised/tests/test_owtsne.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,15 @@ def test_attr_models(self):
self.assertIn(var, controls.attr_shape.model())

def test_multiscale_changed_updates_ui(self):
self.send_signal(self.widget.Inputs.data, self.data)
self.assertFalse(self.widget.controls.multiscale.isChecked())
self.assertTrue(self.widget.perplexity_spin.isEnabled())
self.widget.controls.multiscale.setChecked(True)
self.assertFalse(self.widget.perplexity_spin.isEnabled())

settings = self.widget.settingsHandler.pack_data(self.widget)
w = self.create_widget(OWtSNE, stored_settings=settings)
self.send_signal(w.Inputs.data, self.data, widget=w)
self.assertTrue(w.controls.multiscale.isChecked())
self.assertFalse(w.perplexity_spin.isEnabled())

Expand Down Expand Up @@ -185,8 +187,11 @@ def _check_exaggeration(call, exaggeration):
optimize.return_value = DummyTSNE()(self.data)

# Set value to 1
self.widget.controls.exaggeration.setValue(1)
self.send_signal(self.widget.Inputs.data, self.data)
self.widget.run_button.clicked.emit() # stop initial run
self.wait_until_stop_blocking()
self.widget.controls.exaggeration.setValue(1)
self.widget.run_button.clicked.emit() # run with exaggeration 1
self.wait_until_stop_blocking()
_check_exaggeration(optimize, 1)

Expand All @@ -195,8 +200,11 @@ def _check_exaggeration(call, exaggeration):
optimize.reset_mock()

# Change to 3
self.widget.controls.exaggeration.setValue(3)
self.send_signal(self.widget.Inputs.data, self.data)
self.widget.run_button.clicked.emit() # stop initial run
self.wait_until_stop_blocking()
self.widget.controls.exaggeration.setValue(3)
self.widget.run_button.clicked.emit() # run with exaggeration 1
self.wait_until_stop_blocking()
_check_exaggeration(optimize, 3)

Expand Down

0 comments on commit f77bad6

Please sign in to comment.