From 068315bff393c5aaa2742d9c15fdce295e8f508b Mon Sep 17 00:00:00 2001 From: Vesna Tanko Date: Mon, 17 Oct 2022 13:50:19 +0200 Subject: [PATCH] Annotator: Invalidate clusters on setting change --- orangecontrib/text/widgets/owannotator.py | 2 ++ .../text/widgets/tests/test_owannotator.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/orangecontrib/text/widgets/owannotator.py b/orangecontrib/text/widgets/owannotator.py index 540919fa8..311820ae7 100644 --- a/orangecontrib/text/widgets/owannotator.py +++ b/orangecontrib/text/widgets/owannotator.py @@ -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): @@ -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): diff --git a/orangecontrib/text/widgets/tests/test_owannotator.py b/orangecontrib/text/widgets/tests/test_owannotator.py index 5491e9318..1d263fa2c 100644 --- a/orangecontrib/text/widgets/tests/test_owannotator.py +++ b/orangecontrib/text/widgets/tests/test_owannotator.py @@ -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()