@@ -100,6 +100,38 @@ def test_do_not_recluster_on_same_data(self):
100100 self .commit_and_wait ()
101101 self .assertEqual (call_count + 1 , commit .call_count )
102102
103+ def test_only_recluster_when_necessary_pca_components_change (self ):
104+ # Compute clustering on some data
105+ self .send_signal (self .widget .Inputs .data , self .iris )
106+
107+ # When PCA checkbox is ticked, any update to slider should invalidate results
108+ self .widget .apply_pca_cbx .setChecked (True )
109+ self .widget .pca_components_slider .setValue (2 )
110+ self .commit_and_wait ()
111+
112+ with patch .object (self .widget , '_invalidate_output' ) as invalidate :
113+ # Change slider value, this should invalidate output
114+ self .widget .pca_components_slider .setValue (4 )
115+ self .commit_and_wait ()
116+ self .assertEqual (invalidate .call_count , 1 )
117+
118+ with patch .object (self .widget , '_invalidate_output' ) as invalidate :
119+ # Don't change slider value, this shouldn't do anything
120+ self .widget .pca_components_slider .setValue (4 )
121+ self .commit_and_wait ()
122+ invalidate .assert_not_called ()
123+
124+ # When PCA checkbox is not ticked updating the slider should have no effect
125+ self .widget .apply_pca_cbx .setChecked (False )
126+ self .widget .pca_components_slider .setValue (2 )
127+ self .commit_and_wait ()
128+
129+ with patch .object (self .widget , '_invalidate_output' ) as invalidate :
130+ # Change slider value, this should invalidate output
131+ self .widget .pca_components_slider .setValue (4 )
132+ self .commit_and_wait ()
133+ invalidate .assert_not_called ()
134+
103135 def test_invalidate (self ):
104136 # pylint: disable=protected-access
105137 data = self .iris
0 commit comments