Skip to content

Commit

Permalink
owtsne: fix tests, use simulate util for combobox
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlin-policar committed Oct 27, 2023
1 parent 1da1967 commit 34c79d3
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Orange/widgets/unsupervised/tests/test_owtsne.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from Orange.widgets.tests.base import (
WidgetTest, WidgetOutputsTestMixin, ProjectionWidgetTestMixin
)
from Orange.widgets.tests.utils import simulate
from Orange.widgets.unsupervised.owtsne import OWtSNE, TSNERunner, Task, prepare_tsne_obj


Expand Down Expand Up @@ -779,40 +780,49 @@ def test_controls_ignored_by_distance_matrix_retain_values_on_table_signal(self)
table signals."""
w = self.widget

# SEND IRIS DATA
# Set some parameters
self.send_signal(w.Inputs.data, self.iris)
w.normalize_cbx.setChecked(True)
w.normalize_cbx.setChecked(False)
w.pca_preprocessing_cbx.setChecked(True)
w.pca_component_slider.setValue(3)
w.initialization_combo.setCurrentIndex(0)
w.distance_metric_combo.setCurrentIndex(2)
simulate.combobox_activate_index(w.initialization_combo, 0)
simulate.combobox_activate_index(w.distance_metric_combo, 2)
w.perplexity_spin.setValue(42)
# Disconnect data, save context settings

# Disconnect data
self.send_signal(w.Inputs.data, None)

# Send distances signal
# SEND IRIS DISTANCES
self.send_signal(w.Inputs.distances, self.iris_distances)

# Check that distance-related controls are disabled
self.assertFalse(w.normalize_cbx.isEnabled())

self.assertFalse(w.pca_preprocessing_cbx.isEnabled())
self.assertFalse(w.pca_component_slider.isEnabled())

self.assertFalse(w.initialization_combo.isEnabled())
# Only spectral layout is supported when we have distances
self.assertEqual(w.initialization_combo.currentText(), "Spectral")

self.assertFalse(w.distance_metric_combo.isEnabled())
self.assertEqual(w.distance_metric_combo.currentText(), "")

self.assertTrue(w.perplexity_spin.isEnabled())
self.assertEqual(w.perplexity_spin.value(), 42)
# Disconnect signal, the context settings should not be overridden

# Disconnect distances
self.send_signal(w.Inputs.distances, None)

# Send data signal, the data-only settings should be restored
# SEND IRIS DATA
# The distance-related settings should be restored from when we sent in
# the data, and not overridden by the settings automatically set by the
# widget when we passed in the distances signal
self.send_signal(w.Inputs.data, self.iris)

# Check that the parameters are restored
self.assertTrue(w.normalize_cbx.isEnabled())
self.assertTrue(w.normalize_cbx.isChecked())
self.assertFalse(w.normalize_cbx.isChecked())

self.assertTrue(w.pca_preprocessing_cbx.isEnabled())
self.assertTrue(w.pca_preprocessing_cbx.isChecked())
Expand Down

0 comments on commit 34c79d3

Please sign in to comment.