Skip to content

Commit

Permalink
Annotator: Invalidate clusters on setting change
Browse files Browse the repository at this point in the history
  • Loading branch information
VesnaT committed Oct 17, 2022
1 parent 3077a20 commit 068315b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions orangecontrib/text/widgets/owannotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ def __on_axis_attr_changed(self):

def __on_clustering_type_changed(self):
self._enable_clustering_controls()
self._invalidate_clusters()
self._run()

def __on_epsilon_check_changed(self):
Expand All @@ -343,6 +344,7 @@ def __on_n_components_changed(self):
self._run()

def __on_cluster_var_changed(self):
self._invalidate_clusters()
self._run()

def __on_fdr_threshold_changed(self):
Expand Down
19 changes: 19 additions & 0 deletions orangecontrib/text/widgets/tests/test_owannotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,25 @@ def test_no_disc_var_context(self):
self.widget.controls.clustering_type.buttons[2].click()
self.assertIsNotNone(self.widget.cluster_var)

def test_invalidate(self):
self.send_signal(self.widget.Inputs.corpus, self.corpus)

self.wait_until_finished()
self.assertEqual(len(self.widget.clusters.groups), 1)

self.widget.controls.clustering_type.buttons[1].click()
self.wait_until_finished()
self.assertEqual(len(self.widget.clusters.groups), 3)

self.widget.controls.use_n_components.setChecked(True)
self.widget.controls.n_components.setValue(4)
self.wait_until_finished()
self.assertEqual(len(self.widget.clusters.groups), 4)

self.widget.controls.clustering_type.buttons[2].click()
self.wait_until_finished()
self.assertEqual(len(self.widget.clusters.groups), 2)


if __name__ == "__main__":
unittest.main()

0 comments on commit 068315b

Please sign in to comment.