{
    "file_diffs": [
        {
            "old_file_content": "from itertools import chain\nimport unittest\nfrom unittest.mock import Mock\nfrom queue import Queue\n\nfrom AnyQt.QtGui import QStandardItem\n\nfrom Orange.data import Table\nfrom Orange.widgets.visualize.utils import (\n    VizRankDialog, Result, run_vizrank, QueuedScore\n)\nfrom Orange.widgets.tests.base import WidgetTest\n\n\ndef compute_score(x):\n    return (x[0] + 1) / (x[1] + 1)\n\n\nclass TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state\n\n\nclass TestVizRankDialog(WidgetTest):\n    def test_on_partial_result(self):\n        def iterate_states(initial_state):\n            if initial_state is not None:\n                return chain(states[states.index(initial_state):])\n            return chain(states)\n\n        def invoke_on_partial_result():\n            widget.on_partial_result(run_vizrank(\n                widget.compute_score,\n                widget.iterate_states,\n                widget.saved_state,\n                widget.scores,\n                widget.saved_progress,\n                widget.state_count(),\n                task\n            ))\n\n        task = Mock()\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n\n        widget = VizRankDialog(None)\n        widget.progressBarInit()\n        widget.compute_score = compute_score\n        widget.iterate_states = iterate_states\n        widget.row_for_state = lambda sc, _: [QStandardItem(str(sc))]\n        widget.state_count = lambda: len(states)\n\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        invoke_on_partial_result()\n        self.assertEqual(widget.rank_model.rowCount(), 2)\n        for row, score in enumerate(\n                sorted([compute_score(x) for x in states[:2]])):\n            self.assertEqual(widget.rank_model.item(row, 0).text(), str(score))\n        self.assertEqual(widget.saved_progress, 2)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        invoke_on_partial_result()\n        self.assertEqual(widget.rank_model.rowCount(), 6)\n        for row, score in enumerate(\n                sorted([compute_score(x) for x in states])):\n            self.assertEqual(widget.rank_model.item(row, 0).text(), str(score))\n        self.assertEqual(widget.saved_progress, 6)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n",
            "new_file_content": "from itertools import chain\nimport unittest\nfrom unittest.mock import Mock\nfrom queue import Queue\n\nfrom AnyQt.QtGui import QStandardItem\n\nfrom Orange.data import Table\nfrom Orange.widgets.visualize.utils import (\n    VizRankDialog, Result, run_vizrank, QueuedScore\n)\nfrom Orange.widgets.tests.base import WidgetTest\n\n\ndef compute_score(x):\n    return (x[0] + 1) / (x[1] + 1)\n\n\nclass TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 1)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 3)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state\n\n\nclass TestVizRankDialog(WidgetTest):\n    def test_on_partial_result(self):\n        def iterate_states(initial_state):\n            if initial_state is not None:\n                return chain(states[states.index(initial_state):])\n            return chain(states)\n\n        def invoke_on_partial_result():\n            widget.on_partial_result(run_vizrank(\n                widget.compute_score,\n                widget.iterate_states,\n                widget.saved_state,\n                widget.scores,\n                widget.saved_progress,\n                widget.state_count(),\n                task\n            ))\n\n        task = Mock()\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n\n        widget = VizRankDialog(None)\n        widget.progressBarInit()\n        widget.compute_score = compute_score\n        widget.iterate_states = iterate_states\n        widget.row_for_state = lambda sc, _: [QStandardItem(str(sc))]\n        widget.state_count = lambda: len(states)\n\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        invoke_on_partial_result()\n        self.assertEqual(widget.rank_model.rowCount(), 2)\n        for row, score in enumerate(\n                sorted([compute_score(x) for x in states[:2]])):\n            self.assertEqual(widget.rank_model.item(row, 0).text(), str(score))\n        self.assertEqual(widget.saved_progress, 2)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        invoke_on_partial_result()\n        self.assertEqual(widget.rank_model.rowCount(), 6)\n        for row, score in enumerate(\n                sorted([compute_score(x) for x in states])):\n            self.assertEqual(widget.rank_model.item(row, 0).text(), str(score))\n        self.assertEqual(widget.saved_progress, 6)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n",
            "header": {
                "file": {
                    "path": "Orange/widgets/visualize/tests/test_vizrankdialog.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "fb3f11f98",
                "new_commit_hash": "343bb6e41",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/widgets/visualize/tests/test_vizrankdialog.py"
            },
            "plus_file": {
                "path": "b/Orange/widgets/visualize/tests/test_vizrankdialog.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 41,
                            "length": 7
                        },
                        "new_range": {
                            "start": 41,
                            "length": 7
                        },
                        "section": "class TestRunner(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        res_scores = sorted([compute_score(x) for x in states])",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertListEqual(res.scores, res_scores)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertIsNot(scores, res.scores)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual(task.set_partial_result.call_count, 6)",
                                "type": "deleted"
                            },
                            {
                                "content": "        self.assertEqual(task.set_partial_result.call_count, 2)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(task.set_progress_value.call_count, 7)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_run_vizrank_interrupt(self):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/visualize/tests/test_vizrankdialog.py",
                            "type": "method",
                            "name": "TestRunner.test_run_vizrank",
                            "content": "class TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 29,
                            "end_lineno": 45,
                            "parent": {
                                "file_name": "Orange/widgets/visualize/tests/test_vizrankdialog.py",
                                "type": "class",
                                "name": "TestRunner",
                                "content": "class TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 19,
                                "end_lineno": 93,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/widgets/visualize/tests/test_vizrankdialog.py",
                            "type": "class",
                            "name": "TestRunner",
                            "content": "class TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 19,
                            "end_lineno": 93,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 59,
                            "length": 7
                        },
                        "new_range": {
                            "start": 59,
                            "length": 7
                        },
                        "section": "class TestRunner(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        res_scores = sorted([compute_score(x) for x in states[:2]])",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertListEqual(res.scores, res_scores)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertIsNot(scores, res.scores)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual(task.set_partial_result.call_count, 2)",
                                "type": "deleted"
                            },
                            {
                                "content": "        self.assertEqual(task.set_partial_result.call_count, 1)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(task.set_progress_value.call_count, 3)",
                                "type": "context"
                            },
                            {
                                "content": "        task.set_progress_value.assert_called_with(int(1 / 6 * 100))",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/visualize/tests/test_vizrankdialog.py",
                            "type": "method",
                            "name": "TestRunner.test_run_vizrank_interrupt",
                            "content": "class TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 47,
                            "end_lineno": 81,
                            "parent": {
                                "file_name": "Orange/widgets/visualize/tests/test_vizrankdialog.py",
                                "type": "class",
                                "name": "TestRunner",
                                "content": "class TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 19,
                                "end_lineno": 93,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/widgets/visualize/tests/test_vizrankdialog.py",
                            "type": "class",
                            "name": "TestRunner",
                            "content": "class TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 19,
                            "end_lineno": 93,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 76,
                            "length": 7
                        },
                        "new_range": {
                            "start": 76,
                            "length": 7
                        },
                        "section": "class TestRunner(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        res_scores = sorted([compute_score(x) for x in states])",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertListEqual(res.scores, res_scores)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertIsNot(scores, res.scores)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual(task.set_partial_result.call_count, 6)",
                                "type": "deleted"
                            },
                            {
                                "content": "        self.assertEqual(task.set_partial_result.call_count, 3)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(task.set_progress_value.call_count, 8)",
                                "type": "context"
                            },
                            {
                                "content": "        task.set_progress_value.assert_called_with(int(5 / 6 * 100))",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/visualize/tests/test_vizrankdialog.py",
                            "type": "method",
                            "name": "TestRunner.test_run_vizrank_interrupt",
                            "content": "class TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 47,
                            "end_lineno": 81,
                            "parent": {
                                "file_name": "Orange/widgets/visualize/tests/test_vizrankdialog.py",
                                "type": "class",
                                "name": "TestRunner",
                                "content": "class TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 19,
                                "end_lineno": 93,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/widgets/visualize/tests/test_vizrankdialog.py",
                            "type": "class",
                            "name": "TestRunner",
                            "content": "class TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 6)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 19,
                            "end_lineno": 93,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "\"\"\"\nUtility classes for visualization widgets\n\"\"\"\nimport copy\nfrom bisect import bisect_left\nfrom operator import attrgetter\nfrom queue import Queue, Empty\nfrom types import SimpleNamespace as namespace\nfrom typing import Optional, Iterable, List, Callable\n\nfrom AnyQt.QtCore import Qt, QSize, pyqtSignal as Signal, QSortFilterProxyModel\nfrom AnyQt.QtGui import QStandardItemModel, QStandardItem, QColor, QBrush, QPen\nfrom AnyQt.QtWidgets import (\n    QTableView, QGraphicsTextItem, QGraphicsRectItem, QGraphicsView, QDialog,\n    QVBoxLayout, QLineEdit\n)\nfrom Orange.data import Variable\nfrom Orange.widgets import gui\nfrom Orange.widgets.gui import HorizontalGridDelegate, TableBarItem\nfrom Orange.widgets.utils.concurrent import ConcurrentMixin, TaskState\nfrom Orange.widgets.utils.messages import WidgetMessagesMixin\nfrom Orange.widgets.utils.progressbar import ProgressBarMixin\nfrom Orange.widgets.widget import Msg\n\n\nclass Result(namespace):\n    queue = None  # type: Queue[QueuedScore, ...]\n    scores = None  # type: Optional[List[float, ...]]\n\n\nclass QueuedScore(namespace):\n    position = None  # type: int\n    score = None  # type: float\n    state = None  # type: Iterable\n    next_state = None  # type: Iterable\n\n\nclass VizRankDialog(QDialog, ProgressBarMixin, WidgetMessagesMixin,\n                    ConcurrentMixin):\n    \"\"\"\n    Base class for VizRank dialogs, providing a GUI with a table and a button,\n    and the skeleton for managing the evaluation of visualizations.\n\n    Derived classes must provide methods\n\n    - `iterate_states` for generating combinations (e.g. pairs of attritutes),\n    - `compute_score(state)` for computing the score of a combination,\n    - `row_for_state(state)` that returns a list of items inserted into the\n       table for the given state.\n\n    and, optionally,\n\n    - `state_count` that returns the number of combinations (used for progress\n       bar)\n    - `on_selection_changed` that handles event triggered when the user selects\n      a table row. The method should emit signal\n      `VizRankDialog.selectionChanged(object)`.\n    - `bar_length` returns the length of the bar corresponding to the score.\n\n    The class provides a table and a button. A widget constructs a single\n    instance of this dialog in its `__init__`, like (in Sieve) by using a\n    convenience method :obj:`add_vizrank`::\n\n        self.vizrank, self.vizrank_button = SieveRank.add_vizrank(\n            box, self, \"Score Combinations\", self.set_attr)\n\n    When the widget receives new data, it must call the VizRankDialog's\n    method :obj:`VizRankDialog.initialize()` to clear the GUI and reset the\n    state.\n\n    Clicking the Start button calls method `run` (and renames the button to\n    Pause). Run sets up a progress bar by getting the number of combinations\n    from :obj:`VizRankDialog.state_count()`. It restores the paused state\n    (if any) and calls generator :obj:`VizRankDialog.iterate_states()`. For\n    each generated state, it calls :obj:`VizRankDialog.score(state)`, which\n    must return the score (lower is better) for this state. If the returned\n    state is not `None`, the data returned by `row_for_state` is inserted at\n    the appropriate place in the table.\n\n    Args:\n        master (Orange.widget.OWWidget): widget to which the dialog belongs\n\n    Attributes:\n        master (Orange.widget.OWWidget): widget to which the dialog belongs\n        captionTitle (str): the caption for the dialog. This can be a class\n          attribute. `captionTitle` is used by the `ProgressBarMixin`.\n    \"\"\"\n\n    captionTitle = \"\"\n\n    NEGATIVE_COLOR = QColor(70, 190, 250)\n    POSITIVE_COLOR = QColor(170, 242, 43)\n\n    processingStateChanged = Signal(int)\n    progressBarValueChanged = Signal(float)\n    messageActivated = Signal(Msg)\n    messageDeactivated = Signal(Msg)\n    selectionChanged = Signal(object)\n\n    class Information(WidgetMessagesMixin.Information):\n        nothing_to_rank = Msg(\"There is nothing to rank.\")\n\n    def __init__(self, master):\n        \"\"\"Initialize the attributes and set up the interface\"\"\"\n        QDialog.__init__(self, master, windowTitle=self.captionTitle)\n        WidgetMessagesMixin.__init__(self)\n        ConcurrentMixin.__init__(self)\n        self.setLayout(QVBoxLayout())\n\n        self.insert_message_bar()\n        self.layout().insertWidget(0, self.message_bar)\n        self.master = master\n\n        self.keep_running = False\n        self.scheduled_call = None\n        self.saved_state = None\n        self.saved_progress = 0\n        self.scores = []\n        self.add_to_model = Queue()\n\n        self.filter = QLineEdit()\n        self.filter.setPlaceholderText(\"Filter ...\")\n        self.filter.textChanged.connect(self.filter_changed)\n        self.layout().addWidget(self.filter)\n        # Remove focus from line edit\n        self.setFocus(Qt.ActiveWindowFocusReason)\n\n        self.rank_model = QStandardItemModel(self)\n        self.model_proxy = QSortFilterProxyModel(\n            self, filterCaseSensitivity=False)\n        self.model_proxy.setSourceModel(self.rank_model)\n        self.rank_table = view = QTableView(\n            selectionBehavior=QTableView.SelectRows,\n            selectionMode=QTableView.SingleSelection,\n            showGrid=False,\n            editTriggers=gui.TableView.NoEditTriggers)\n        if self._has_bars:\n            view.setItemDelegate(TableBarItem())\n        else:\n            view.setItemDelegate(HorizontalGridDelegate())\n        view.setModel(self.model_proxy)\n        view.selectionModel().selectionChanged.connect(\n            self.on_selection_changed)\n        view.horizontalHeader().setStretchLastSection(True)\n        view.horizontalHeader().hide()\n        self.layout().addWidget(view)\n\n        self.button = gui.button(\n            self, self, \"Start\", callback=self.toggle, default=True)\n\n    @property\n    def _has_bars(self):\n        return type(self).bar_length is not VizRankDialog.bar_length\n\n    @classmethod\n    def add_vizrank(cls, widget, master, button_label, set_attr_callback):\n        \"\"\"\n        Equip the widget with VizRank button and dialog, and monkey patch the\n        widget's `closeEvent` and `hideEvent` to close/hide the vizrank, too.\n\n        Args:\n            widget (QWidget): the widget into whose layout to insert the button\n            master (Orange.widgets.widget.OWWidget): the master widget\n            button_label: the label for the button\n            set_attr_callback: the callback for setting the projection chosen\n                in the vizrank\n\n        Returns:\n            tuple with Vizrank dialog instance and push button\n        \"\"\"\n        # Monkey patching could be avoided by mixing-in the class (not\n        # necessarily a good idea since we can make a mess of multiple\n        # defined/derived closeEvent and hideEvent methods). Furthermore,\n        # per-class patching would be better than per-instance, but we don't\n        # want to mess with meta-classes either.\n\n        vizrank = cls(master)\n        button = gui.button(\n            widget, master, button_label, callback=vizrank.reshow,\n            enabled=False)\n        vizrank.selectionChanged.connect(lambda args: set_attr_callback(*args))\n\n        master_close_event = master.closeEvent\n        master_hide_event = master.hideEvent\n        master_delete_event = master.onDeleteWidget\n\n        def closeEvent(event):\n            vizrank.close()\n            master_close_event(event)\n\n        def hideEvent(event):\n            vizrank.hide()\n            master_hide_event(event)\n\n        def deleteEvent():\n            vizrank.keep_running = False\n            vizrank.shutdown()\n            master_delete_event()\n\n        master.closeEvent = closeEvent\n        master.hideEvent = hideEvent\n        master.onDeleteWidget = deleteEvent\n        return vizrank, button\n\n    def reshow(self):\n        \"\"\"Put the widget on top of all windows\n        \"\"\"\n        self.show()\n        self.raise_()\n        self.activateWindow()\n\n    def initialize(self):\n        \"\"\"\n        Clear and initialize the dialog.\n\n        This method must be called by the widget when the data is reset,\n        e.g. from `set_data` handler.\n        \"\"\"\n        if self.task is not None:\n            self.keep_running = False\n            self.cancel()\n        self.keep_running = False\n        self.scheduled_call = None\n        self.saved_state = None\n        self.saved_progress = 0\n        self.progressBarFinished()\n        self.scores = []\n        self._update_model()  # empty queue\n        self.rank_model.clear()\n        self.button.setText(\"Start\")\n        self.button.setEnabled(self.check_preconditions())\n\n    def filter_changed(self, text):\n        self.model_proxy.setFilterFixedString(text)\n\n    def stop_and_reset(self, reset_method=None):\n        if self.keep_running:\n            self.scheduled_call = reset_method or self.initialize\n            self.keep_running = False\n        else:\n            self.initialize()\n\n    def check_preconditions(self):\n        \"\"\"Check whether there is sufficient data for ranking.\"\"\"\n        return True\n\n    def on_selection_changed(self, selected, deselected):\n        \"\"\"\n        Set the new visualization in the widget when the user select a\n        row in the table.\n\n        If derived class does not reimplement this, the table gives the\n        information but the user can't click it to select the visualization.\n\n        Args:\n            selected: the index of the selected item\n            deselected: the index of the previously selected item\n        \"\"\"\n        pass\n\n    def iterate_states(self, initial_state):\n        \"\"\"\n        Generate all possible states (e.g. attribute combinations) for the\n        given data. The content of the generated states is specific to the\n        visualization.\n\n        This method must be defined in the derived classes.\n\n        Args:\n            initial_state: initial state; None if this is the first call\n        \"\"\"\n        raise NotImplementedError\n\n    def state_count(self):\n        \"\"\"\n        Return the number of states for the progress bar.\n\n        Derived classes should implement this to ensure the proper behaviour of\n        the progress bar\"\"\"\n        return 0\n\n    def compute_score(self, state):\n        \"\"\"\n        Abstract method for computing the score for the given state. Smaller\n        scores are better.\n\n        Args:\n            state: the state, e.g. the combination of attributes as generated\n                by :obj:`state_count`.\n        \"\"\"\n        raise NotImplementedError\n\n    def bar_length(self, score):\n        \"\"\"Compute the bar length (between 0 and 1) corresponding to the score.\n        Return `None` if the score cannot be normalized.\n        \"\"\"\n        return None\n\n    def row_for_state(self, score, state):\n        \"\"\"\n        Abstract method that return the items that are inserted into the table.\n\n        Args:\n            score: score, computed by :obj:`compute_score`\n            state: the state, e.g. combination of attributes\n            \"\"\"\n        raise NotImplementedError\n\n    def _select_first_if_none(self):\n        if not self.rank_table.selectedIndexes():\n            self.rank_table.selectRow(0)\n\n    def on_partial_result(self, result: Result):\n        try:\n            while True:\n                queued = result.queue.get_nowait()\n                self.saved_state = queued.next_state\n                self.add_to_model.put_nowait(queued)\n        except Empty:\n            pass\n        self.scores = result.scores\n        self.saved_progress = len(self.scores)\n        self._update()\n\n    def on_done(self, result: Result):\n        self.button.setText(\"Finished\")\n        self.button.setEnabled(False)\n        self.keep_running = False\n        self.saved_state = None\n        self._stopped()\n\n    def _stopped(self):\n        self.progressBarFinished()\n        self._update_model()\n        self.stopped()\n        if self.scheduled_call:\n            self.scheduled_call()\n        self._select_first_if_none()\n\n    def _update(self):\n        self._update_model()\n        self._update_progress()\n\n    def _update_progress(self):\n        self.progressBarSet(int(self.saved_progress * 100 / max(1, self.state_count())))\n\n    def _update_model(self):\n        try:\n            while True:\n                queued = self.add_to_model.get_nowait()\n                row_items = self.row_for_state(queued.score, queued.state)\n                bar_length = self.bar_length(queued.score)\n                if bar_length is not None:\n                    row_items[0].setData(bar_length,\n                                         gui.TableBarItem.BarRole)\n                self.rank_model.insertRow(queued.position, row_items)\n        except Empty:\n            pass\n\n    def toggle(self):\n        \"\"\"Start or pause the computation.\"\"\"\n        self.keep_running = not self.keep_running\n        if self.keep_running:\n            self.button.setText(\"Pause\")\n            self.button.repaint()\n            self.progressBarInit()\n            self.before_running()\n            self.start(run_vizrank, self.compute_score,\n                       self.iterate_states, self.saved_state, self.scores,\n                       self.saved_progress, self.state_count())\n        else:\n            self.button.setText(\"Continue\")\n            self.button.repaint()\n            self.cancel()\n            self._stopped()\n\n    def before_running(self):\n        \"\"\"Code that is run before running vizrank in its own thread\"\"\"\n        pass\n\n    def stopped(self):\n        \"\"\"Code that is run after stopping the vizrank thread\"\"\"\n        pass\n\n\ndef run_vizrank(compute_score: Callable, iterate_states: Callable,\n                saved_state: Optional[Iterable], scores: List,\n                progress: int, state_count: int, task: TaskState):\n    task.set_status(\"Getting combinations...\")\n    task.set_progress_value(0.1)\n    states = iterate_states(saved_state)\n\n    task.set_status(\"Getting scores...\")\n    res = Result(queue=Queue(), scores=None)\n    scores = scores.copy()\n\n    def do_work(st, next_st):\n        try:\n            score = compute_score(st)\n            if score is not None:\n                pos = bisect_left(scores, score)\n                res.queue.put_nowait(QueuedScore(position=pos, score=score,\n                                                 state=st, next_state=next_st))\n                scores.insert(pos, score)\n        except Exception:  # ignore current state in case of any problem\n            pass\n        res.scores = scores.copy()\n        task.set_partial_result(res)\n\n    state = None\n    next_state = next(states)\n    try:\n        while True:\n            if task.is_interruption_requested():\n                return res\n            task.set_progress_value(int(progress * 100 / max(1, state_count)))\n            progress += 1\n            state = copy.copy(next_state)\n            next_state = copy.copy(next(states))\n            do_work(state, next_state)\n    except StopIteration:\n        do_work(state, None)\n    return res\n\n\nclass VizRankDialogAttr(VizRankDialog):\n    \"\"\"\n    VizRank dialog for single attributes. The class provides most of the\n    needed methods, except for `initialize` which is expected to store a\n    list of `Variable` instances to `self.attrs`, and method\n    `compute_score(state)` for scoring the combinations.\n\n    The state is an attribute index.\n\n    When the user selects an attribute, the dialog emits signal\n    `selectionChanged` with the attribute as parameter.\n    \"\"\"\n\n    attrSelected = Signal(Variable, Variable)\n    _AttrRole = next(gui.OrangeUserRole)\n\n    def __init__(self, master):\n        super().__init__(master)\n        self.attrs = []\n\n    def sizeHint(self):\n        \"\"\"Assuming a single columns in the table, return `QSize(160, 512)` as\n        a reasonable default size.\"\"\"\n        return QSize(160, 512)\n\n    def check_preconditions(self):\n        \"\"\"Refuse ranking if there are no features or instances.\"\"\"\n        can_rank = self.master.data is not None and \\\n            self.master.data.domain.attributes and \\\n            len(self.master.data) != 0\n        self.Information.nothing_to_rank(shown=not can_rank)\n        return can_rank\n\n    def on_selection_changed(self, selected, deselected):\n        if not selected.isEmpty():\n            attr = selected.indexes()[0].data(self._AttrRole)\n            self.attrSelected.emit(attr)\n\n    def state_count(self):\n        return len(self.attrs)\n\n    def iterate_states(self, initial_state):\n        yield from range(initial_state or 0, len(self.attrs))\n\n    def row_for_state(self, score, state):\n        attr = self.attrs[state]\n        item = QStandardItem(attr.name)\n        item.setData(attr, self._AttrRole)\n        return [item]\n\n\nclass VizRankDialogAttrPair(VizRankDialog):\n    \"\"\"\n    VizRank dialog for pairs of attributes. The class provides most of the\n    needed methods, except for `initialize` which is expected to store a\n    list of `Variable` instances to `self.attrs`, and method\n    `compute_score(state)` for scoring the combinations.\n\n    The state is a pair of indices into `self.attrs`.\n\n    When the user selects a pair, the dialog emits signal `selectionChanged`\n    with a tuple of variables as parameter.\n    \"\"\"\n\n    pairSelected = Signal(Variable, Variable)\n    _AttrRole = next(gui.OrangeUserRole)\n\n    def __init__(self, master):\n        VizRankDialog.__init__(self, master)\n        self.resize(320, 512)\n        self.attrs = []\n        manual_change_signal = getattr(master, \"xy_changed_manually\", None)\n        if manual_change_signal:\n            manual_change_signal.connect(self.on_manual_change)\n\n    def sizeHint(self):\n        \"\"\"Assuming two columns in the table, return `QSize(320, 512)` as\n        a reasonable default size.\"\"\"\n        return QSize(320, 512)\n\n    def check_preconditions(self):\n        \"\"\"Refuse ranking if there are less than two feature or instances.\"\"\"\n        can_rank = self.master.data is not None and \\\n            len(self.master.data.domain.attributes) >= 2 and \\\n            len(self.master.data) >= 2\n        self.Information.nothing_to_rank(shown=not can_rank)\n        return can_rank\n\n    def on_selection_changed(self, selected, deselected):\n        selection = selected.indexes()\n        if not selection:\n            return\n        attrs = selected.indexes()[0].data(self._AttrRole)\n        self.selectionChanged.emit(attrs)\n\n    def on_manual_change(self, attr1, attr2):\n        model = self.rank_model\n        self.rank_table.selectionModel().clear()\n        for row in range(model.rowCount()):\n            a1, a2 = model.data(model.index(row, 0), self._AttrRole)\n            if a1 is attr1 and a2 is attr2:\n                self.rank_table.selectRow(row)\n                return\n\n    def state_count(self):\n        n_attrs = len(self.attrs)\n        return n_attrs * (n_attrs - 1) / 2\n\n    def iterate_states(self, initial_state):\n        si, sj = initial_state or (0, 0)\n        for i in range(si, len(self.attrs)):\n            for j in range(sj, i):\n                yield i, j\n            sj = 0\n\n    def row_for_state(self, score, state):\n        attrs = sorted((self.attrs[x] for x in state), key=attrgetter(\"name\"))\n        item = QStandardItem(\", \".join(a.name for a in attrs))\n        item.setData(attrs, self._AttrRole)\n        return [item]\n\n\nclass CanvasText(QGraphicsTextItem):\n    \"\"\"QGraphicsTextItem with more convenient constructor\n\n       Args:\n           scene (QGraphicsScene): scene into which the text is placed\n           text (str): text; see also argument `html_text` (default: `\"\"`)\n           x (int): x-coordinate (default: 0)\n           y (int): y-coordinate (default: 0)\n           alignment (Qt.Alignment): text alignment\n               (default: Qt.AlignLeft | Qt.AlignTop)\n           bold (bool): if `True`, font is set to bold (default: `False`)\n           font (QFont): text font\n           z (int): text layer\n           html_text (str): text as html; if present (default is `None`),\n               it overrides the `text` argument\n           tooltip (str): text tooltip\n           show (bool): if `False`, the text is hidden (default: `True`)\n           vertical (bool): if `True`, the text is rotated by 90 degrees\n               (default: `False`)\n    \"\"\"\n    def __init__(self, scene, text=\"\", x=0, y=0,\n                 alignment=Qt.AlignLeft | Qt.AlignTop, bold=False, font=None,\n                 z=0, html_text=None, tooltip=None, show=True, vertical=False,\n                 max_width=None):\n        QGraphicsTextItem.__init__(self, text, None)\n\n        if font:\n            self.setFont(font)\n        if bold:\n            font = self.font()\n            font.setBold(bold)\n            self.setFont(font)\n        if html_text:\n            self.setHtml(html_text)\n\n        self.alignment = alignment\n        self.vertical = vertical\n        if vertical:\n            self.setRotation(-90)\n\n        self.setPos(x, y)\n        self.x, self.y = x, y\n        self.setZValue(z)\n        if tooltip:\n            self.setToolTip(tooltip)\n        if max_width is not None:\n            assert not html_text\n            self.elide(max_width)\n\n        if show:\n            self.show()\n        else:\n            self.hide()\n\n        if scene is not None:\n            scene.addItem(self)\n\n    def elide(self, max_width):\n        if self.boundingRect().width() <= max_width:\n            return\n        short = self.toPlainText()\n        if not self.toolTip():\n            self.setToolTip(short)\n        while short and self.boundingRect().width() > max_width:\n            short = short[:-1]\n            self.setPlainText(short + \"...\")\n            # apparently this has to be called to reset position\n            self.setPos(self.x, self.y)\n\n    def setPos(self, x, y):\n        \"\"\"setPos with adjustment for alignment\"\"\"\n        self.x, self.y = x, y\n        rect = QGraphicsTextItem.boundingRect(self)\n        if self.vertical:\n            h, w = rect.height(), rect.width()\n            rect.setWidth(h)\n            rect.setHeight(-w)\n        if int(self.alignment & Qt.AlignRight):\n            x -= rect.width()\n        elif int(self.alignment & Qt.AlignHCenter):\n            x -= rect.width() / 2.\n        if int(self.alignment & Qt.AlignBottom):\n            y -= rect.height()\n        elif int(self.alignment & Qt.AlignVCenter):\n            y -= rect.height() / 2.\n        QGraphicsTextItem.setPos(self, x, y)\n\n\nclass CanvasRectangle(QGraphicsRectItem):\n    \"\"\"QGraphicsRectItem with more convenient constructor\n\n    Args:\n        scene (QGraphicsScene): scene into which the rectangle is placed\n        x (int): x-coordinate (default: 0)\n        y (int): y-coordinate (default: 0)\n        width (int): rectangle's width (default: 0)\n        height (int): rectangle's height (default: 0)\n        z (int): z-layer\n        pen (QPen): pen for the border; if present, it overrides the separate\n            arguments for color, width and style\n        pen_color (QColor or QPen): the (color of) the pen\n            (default: `QColor(128, 128, 128)`)\n        pen_width (int): pen width\n        pen_style (PenStyle): pen style (default: `Qt.SolidLine`)\n        brush_color (QColor): the color for the interior (default: same as pen)\n        tooltip (str): tooltip\n        show (bool): if `False`, the text is hidden (default: `True`)\n        onclick (callable): callback for mouse click event\n    \"\"\"\n\n    def __init__(self, scene, x=0, y=0, width=0, height=0,\n                 pen_color=QColor(128, 128, 128), brush_color=None, pen_width=1,\n                 z=0, pen_style=Qt.SolidLine, pen=None, tooltip=None, show=True,\n                 onclick=None):\n        super().__init__(x, y, width, height, None)\n        self.onclick = onclick\n        if brush_color:\n            self.setBrush(QBrush(brush_color))\n        if pen:\n            self.setPen(pen)\n        else:\n            self.setPen(QPen(QBrush(pen_color), pen_width, pen_style))\n        self.setZValue(z)\n        if tooltip:\n            self.setToolTip(tooltip)\n        if show:\n            self.show()\n        else:\n            self.hide()\n\n        if scene is not None:\n            scene.addItem(self)\n\n    def mousePressEvent(self, event):\n        if self.onclick:\n            self.onclick(self, event)\n\n\nclass ViewWithPress(QGraphicsView):\n    \"\"\"QGraphicsView with a callback for mouse press event. The callback\n    is given as keyword argument `handler`.\n    \"\"\"\n    def __init__(self, *args, **kwargs):\n        self.handler = kwargs.pop(\"handler\")\n        super().__init__(*args)\n\n    def mousePressEvent(self, event):\n        super().mousePressEvent(event)\n        if not event.isAccepted():\n            self.handler()\n",
            "new_file_content": "\"\"\"\nUtility classes for visualization widgets\n\"\"\"\nimport copy\nfrom bisect import bisect_left\nfrom operator import attrgetter\nfrom queue import Queue, Empty\nfrom types import SimpleNamespace as namespace\nfrom typing import Optional, Iterable, List, Callable\nfrom threading import Timer\n\nfrom AnyQt.QtCore import Qt, QSize, pyqtSignal as Signal, QSortFilterProxyModel\nfrom AnyQt.QtGui import QStandardItemModel, QStandardItem, QColor, QBrush, QPen\nfrom AnyQt.QtWidgets import (\n    QTableView, QGraphicsTextItem, QGraphicsRectItem, QGraphicsView, QDialog,\n    QVBoxLayout, QLineEdit\n)\nfrom Orange.data import Variable\nfrom Orange.widgets import gui\nfrom Orange.widgets.gui import HorizontalGridDelegate, TableBarItem\nfrom Orange.widgets.utils.concurrent import ConcurrentMixin, TaskState\nfrom Orange.widgets.utils.messages import WidgetMessagesMixin\nfrom Orange.widgets.utils.progressbar import ProgressBarMixin\nfrom Orange.widgets.widget import Msg\n\n\nclass Result(namespace):\n    queue = None  # type: Queue[QueuedScore, ...]\n    scores = None  # type: Optional[List[float, ...]]\n\n\nclass QueuedScore(namespace):\n    position = None  # type: int\n    score = None  # type: float\n    state = None  # type: Iterable\n    next_state = None  # type: Iterable\n\n\nclass VizRankDialog(QDialog, ProgressBarMixin, WidgetMessagesMixin,\n                    ConcurrentMixin):\n    \"\"\"\n    Base class for VizRank dialogs, providing a GUI with a table and a button,\n    and the skeleton for managing the evaluation of visualizations.\n\n    Derived classes must provide methods\n\n    - `iterate_states` for generating combinations (e.g. pairs of attritutes),\n    - `compute_score(state)` for computing the score of a combination,\n    - `row_for_state(state)` that returns a list of items inserted into the\n       table for the given state.\n\n    and, optionally,\n\n    - `state_count` that returns the number of combinations (used for progress\n       bar)\n    - `on_selection_changed` that handles event triggered when the user selects\n      a table row. The method should emit signal\n      `VizRankDialog.selectionChanged(object)`.\n    - `bar_length` returns the length of the bar corresponding to the score.\n\n    The class provides a table and a button. A widget constructs a single\n    instance of this dialog in its `__init__`, like (in Sieve) by using a\n    convenience method :obj:`add_vizrank`::\n\n        self.vizrank, self.vizrank_button = SieveRank.add_vizrank(\n            box, self, \"Score Combinations\", self.set_attr)\n\n    When the widget receives new data, it must call the VizRankDialog's\n    method :obj:`VizRankDialog.initialize()` to clear the GUI and reset the\n    state.\n\n    Clicking the Start button calls method `run` (and renames the button to\n    Pause). Run sets up a progress bar by getting the number of combinations\n    from :obj:`VizRankDialog.state_count()`. It restores the paused state\n    (if any) and calls generator :obj:`VizRankDialog.iterate_states()`. For\n    each generated state, it calls :obj:`VizRankDialog.score(state)`, which\n    must return the score (lower is better) for this state. If the returned\n    state is not `None`, the data returned by `row_for_state` is inserted at\n    the appropriate place in the table.\n\n    Args:\n        master (Orange.widget.OWWidget): widget to which the dialog belongs\n\n    Attributes:\n        master (Orange.widget.OWWidget): widget to which the dialog belongs\n        captionTitle (str): the caption for the dialog. This can be a class\n          attribute. `captionTitle` is used by the `ProgressBarMixin`.\n    \"\"\"\n\n    captionTitle = \"\"\n\n    NEGATIVE_COLOR = QColor(70, 190, 250)\n    POSITIVE_COLOR = QColor(170, 242, 43)\n\n    processingStateChanged = Signal(int)\n    progressBarValueChanged = Signal(float)\n    messageActivated = Signal(Msg)\n    messageDeactivated = Signal(Msg)\n    selectionChanged = Signal(object)\n\n    class Information(WidgetMessagesMixin.Information):\n        nothing_to_rank = Msg(\"There is nothing to rank.\")\n\n    def __init__(self, master):\n        \"\"\"Initialize the attributes and set up the interface\"\"\"\n        QDialog.__init__(self, master, windowTitle=self.captionTitle)\n        WidgetMessagesMixin.__init__(self)\n        ConcurrentMixin.__init__(self)\n        self.setLayout(QVBoxLayout())\n\n        self.insert_message_bar()\n        self.layout().insertWidget(0, self.message_bar)\n        self.master = master\n\n        self.keep_running = False\n        self.scheduled_call = None\n        self.saved_state = None\n        self.saved_progress = 0\n        self.scores = []\n        self.add_to_model = Queue()\n\n        self.filter = QLineEdit()\n        self.filter.setPlaceholderText(\"Filter ...\")\n        self.filter.textChanged.connect(self.filter_changed)\n        self.layout().addWidget(self.filter)\n        # Remove focus from line edit\n        self.setFocus(Qt.ActiveWindowFocusReason)\n\n        self.rank_model = QStandardItemModel(self)\n        self.model_proxy = QSortFilterProxyModel(\n            self, filterCaseSensitivity=False)\n        self.model_proxy.setSourceModel(self.rank_model)\n        self.rank_table = view = QTableView(\n            selectionBehavior=QTableView.SelectRows,\n            selectionMode=QTableView.SingleSelection,\n            showGrid=False,\n            editTriggers=gui.TableView.NoEditTriggers)\n        if self._has_bars:\n            view.setItemDelegate(TableBarItem())\n        else:\n            view.setItemDelegate(HorizontalGridDelegate())\n        view.setModel(self.model_proxy)\n        view.selectionModel().selectionChanged.connect(\n            self.on_selection_changed)\n        view.horizontalHeader().setStretchLastSection(True)\n        view.horizontalHeader().hide()\n        self.layout().addWidget(view)\n\n        self.button = gui.button(\n            self, self, \"Start\", callback=self.toggle, default=True)\n\n    @property\n    def _has_bars(self):\n        return type(self).bar_length is not VizRankDialog.bar_length\n\n    @classmethod\n    def add_vizrank(cls, widget, master, button_label, set_attr_callback):\n        \"\"\"\n        Equip the widget with VizRank button and dialog, and monkey patch the\n        widget's `closeEvent` and `hideEvent` to close/hide the vizrank, too.\n\n        Args:\n            widget (QWidget): the widget into whose layout to insert the button\n            master (Orange.widgets.widget.OWWidget): the master widget\n            button_label: the label for the button\n            set_attr_callback: the callback for setting the projection chosen\n                in the vizrank\n\n        Returns:\n            tuple with Vizrank dialog instance and push button\n        \"\"\"\n        # Monkey patching could be avoided by mixing-in the class (not\n        # necessarily a good idea since we can make a mess of multiple\n        # defined/derived closeEvent and hideEvent methods). Furthermore,\n        # per-class patching would be better than per-instance, but we don't\n        # want to mess with meta-classes either.\n\n        vizrank = cls(master)\n        button = gui.button(\n            widget, master, button_label, callback=vizrank.reshow,\n            enabled=False)\n        vizrank.selectionChanged.connect(lambda args: set_attr_callback(*args))\n\n        master_close_event = master.closeEvent\n        master_hide_event = master.hideEvent\n        master_delete_event = master.onDeleteWidget\n\n        def closeEvent(event):\n            vizrank.close()\n            master_close_event(event)\n\n        def hideEvent(event):\n            vizrank.hide()\n            master_hide_event(event)\n\n        def deleteEvent():\n            vizrank.keep_running = False\n            vizrank.shutdown()\n            master_delete_event()\n\n        master.closeEvent = closeEvent\n        master.hideEvent = hideEvent\n        master.onDeleteWidget = deleteEvent\n        return vizrank, button\n\n    def reshow(self):\n        \"\"\"Put the widget on top of all windows\n        \"\"\"\n        self.show()\n        self.raise_()\n        self.activateWindow()\n\n    def initialize(self):\n        \"\"\"\n        Clear and initialize the dialog.\n\n        This method must be called by the widget when the data is reset,\n        e.g. from `set_data` handler.\n        \"\"\"\n        if self.task is not None:\n            self.keep_running = False\n            self.cancel()\n        self.keep_running = False\n        self.scheduled_call = None\n        self.saved_state = None\n        self.saved_progress = 0\n        self.progressBarFinished()\n        self.scores = []\n        self._update_model()  # empty queue\n        self.rank_model.clear()\n        self.button.setText(\"Start\")\n        self.button.setEnabled(self.check_preconditions())\n\n    def filter_changed(self, text):\n        self.model_proxy.setFilterFixedString(text)\n\n    def stop_and_reset(self, reset_method=None):\n        if self.keep_running:\n            self.scheduled_call = reset_method or self.initialize\n            self.keep_running = False\n        else:\n            self.initialize()\n\n    def check_preconditions(self):\n        \"\"\"Check whether there is sufficient data for ranking.\"\"\"\n        return True\n\n    def on_selection_changed(self, selected, deselected):\n        \"\"\"\n        Set the new visualization in the widget when the user select a\n        row in the table.\n\n        If derived class does not reimplement this, the table gives the\n        information but the user can't click it to select the visualization.\n\n        Args:\n            selected: the index of the selected item\n            deselected: the index of the previously selected item\n        \"\"\"\n        pass\n\n    def iterate_states(self, initial_state):\n        \"\"\"\n        Generate all possible states (e.g. attribute combinations) for the\n        given data. The content of the generated states is specific to the\n        visualization.\n\n        This method must be defined in the derived classes.\n\n        Args:\n            initial_state: initial state; None if this is the first call\n        \"\"\"\n        raise NotImplementedError\n\n    def state_count(self):\n        \"\"\"\n        Return the number of states for the progress bar.\n\n        Derived classes should implement this to ensure the proper behaviour of\n        the progress bar\"\"\"\n        return 0\n\n    def compute_score(self, state):\n        \"\"\"\n        Abstract method for computing the score for the given state. Smaller\n        scores are better.\n\n        Args:\n            state: the state, e.g. the combination of attributes as generated\n                by :obj:`state_count`.\n        \"\"\"\n        raise NotImplementedError\n\n    def bar_length(self, score):\n        \"\"\"Compute the bar length (between 0 and 1) corresponding to the score.\n        Return `None` if the score cannot be normalized.\n        \"\"\"\n        return None\n\n    def row_for_state(self, score, state):\n        \"\"\"\n        Abstract method that return the items that are inserted into the table.\n\n        Args:\n            score: score, computed by :obj:`compute_score`\n            state: the state, e.g. combination of attributes\n            \"\"\"\n        raise NotImplementedError\n\n    def _select_first_if_none(self):\n        if not self.rank_table.selectedIndexes():\n            self.rank_table.selectRow(0)\n\n    def on_partial_result(self, result: Result):\n        try:\n            while True:\n                queued = result.queue.get_nowait()\n                self.saved_state = queued.next_state\n                self.add_to_model.put_nowait(queued)\n        except Empty:\n            pass\n        self.scores = result.scores\n        self.saved_progress = len(self.scores)\n        self._update()\n\n    def on_done(self, result: Result):\n        self.button.setText(\"Finished\")\n        self.button.setEnabled(False)\n        self.keep_running = False\n        self.saved_state = None\n        self._stopped()\n\n    def _stopped(self):\n        self.progressBarFinished()\n        self._update_model()\n        self.stopped()\n        if self.scheduled_call:\n            self.scheduled_call()\n        self._select_first_if_none()\n\n    def _update(self):\n        self._update_model()\n        self._update_progress()\n\n    def _update_progress(self):\n        self.progressBarSet(int(self.saved_progress * 100 / max(1, self.state_count())))\n\n    def _update_model(self):\n        try:\n            while True:\n                queued = self.add_to_model.get_nowait()\n                row_items = self.row_for_state(queued.score, queued.state)\n                bar_length = self.bar_length(queued.score)\n                if bar_length is not None:\n                    row_items[0].setData(bar_length,\n                                         gui.TableBarItem.BarRole)\n                self.rank_model.insertRow(queued.position, row_items)\n        except Empty:\n            pass\n\n    def toggle(self):\n        \"\"\"Start or pause the computation.\"\"\"\n        self.keep_running = not self.keep_running\n        if self.keep_running:\n            self.button.setText(\"Pause\")\n            self.button.repaint()\n            self.progressBarInit()\n            self.before_running()\n            self.start(run_vizrank, self.compute_score,\n                       self.iterate_states, self.saved_state, self.scores,\n                       self.saved_progress, self.state_count())\n        else:\n            self.button.setText(\"Continue\")\n            self.button.repaint()\n            self.cancel()\n            self._stopped()\n\n    def before_running(self):\n        \"\"\"Code that is run before running vizrank in its own thread\"\"\"\n        pass\n\n    def stopped(self):\n        \"\"\"Code that is run after stopping the vizrank thread\"\"\"\n        pass\n\n\ndef run_vizrank(compute_score: Callable, iterate_states: Callable,\n                saved_state: Optional[Iterable], scores: List,\n                progress: int, state_count: int, task: TaskState):\n    task.set_status(\"Getting combinations...\")\n    task.set_progress_value(0.1)\n    states = iterate_states(saved_state)\n\n    task.set_status(\"Getting scores...\")\n    res = Result(queue=Queue(), scores=None)\n    scores = scores.copy()\n    can_set_partial_result = True\n\n    def do_work(st, next_st):\n        try:\n            score = compute_score(st)\n            if score is not None:\n                pos = bisect_left(scores, score)\n                res.queue.put_nowait(QueuedScore(position=pos, score=score,\n                                                 state=st, next_state=next_st))\n                scores.insert(pos, score)\n        except Exception:  # ignore current state in case of any problem\n            pass\n        res.scores = scores.copy()\n\n    def reset_flag():\n        nonlocal can_set_partial_result\n        can_set_partial_result = True\n\n    state = None\n    next_state = next(states)\n    try:\n        while True:\n            if task.is_interruption_requested():\n                return res\n            task.set_progress_value(int(progress * 100 / max(1, state_count)))\n            progress += 1\n            state = copy.copy(next_state)\n            next_state = copy.copy(next(states))\n            do_work(state, next_state)\n            # for simple scores (e.g. correlations widget) and many feature\n            # combinations, the 'partial_result_ready' signal (emitted by\n            # invoking 'task.set_partial_result') was emitted too frequently\n            # for a longer period of time and therefore causing the widget\n            # being unresponsive\n            if can_set_partial_result:\n                task.set_partial_result(res)\n                can_set_partial_result = False\n                Timer(0.01, reset_flag).start()\n    except StopIteration:\n        do_work(state, None)\n        task.set_partial_result(res)\n    return res\n\n\nclass VizRankDialogAttr(VizRankDialog):\n    \"\"\"\n    VizRank dialog for single attributes. The class provides most of the\n    needed methods, except for `initialize` which is expected to store a\n    list of `Variable` instances to `self.attrs`, and method\n    `compute_score(state)` for scoring the combinations.\n\n    The state is an attribute index.\n\n    When the user selects an attribute, the dialog emits signal\n    `selectionChanged` with the attribute as parameter.\n    \"\"\"\n\n    attrSelected = Signal(Variable, Variable)\n    _AttrRole = next(gui.OrangeUserRole)\n\n    def __init__(self, master):\n        super().__init__(master)\n        self.attrs = []\n\n    def sizeHint(self):\n        \"\"\"Assuming a single columns in the table, return `QSize(160, 512)` as\n        a reasonable default size.\"\"\"\n        return QSize(160, 512)\n\n    def check_preconditions(self):\n        \"\"\"Refuse ranking if there are no features or instances.\"\"\"\n        can_rank = self.master.data is not None and \\\n            self.master.data.domain.attributes and \\\n            len(self.master.data) != 0\n        self.Information.nothing_to_rank(shown=not can_rank)\n        return can_rank\n\n    def on_selection_changed(self, selected, deselected):\n        if not selected.isEmpty():\n            attr = selected.indexes()[0].data(self._AttrRole)\n            self.attrSelected.emit(attr)\n\n    def state_count(self):\n        return len(self.attrs)\n\n    def iterate_states(self, initial_state):\n        yield from range(initial_state or 0, len(self.attrs))\n\n    def row_for_state(self, score, state):\n        attr = self.attrs[state]\n        item = QStandardItem(attr.name)\n        item.setData(attr, self._AttrRole)\n        return [item]\n\n\nclass VizRankDialogAttrPair(VizRankDialog):\n    \"\"\"\n    VizRank dialog for pairs of attributes. The class provides most of the\n    needed methods, except for `initialize` which is expected to store a\n    list of `Variable` instances to `self.attrs`, and method\n    `compute_score(state)` for scoring the combinations.\n\n    The state is a pair of indices into `self.attrs`.\n\n    When the user selects a pair, the dialog emits signal `selectionChanged`\n    with a tuple of variables as parameter.\n    \"\"\"\n\n    pairSelected = Signal(Variable, Variable)\n    _AttrRole = next(gui.OrangeUserRole)\n\n    def __init__(self, master):\n        VizRankDialog.__init__(self, master)\n        self.resize(320, 512)\n        self.attrs = []\n        manual_change_signal = getattr(master, \"xy_changed_manually\", None)\n        if manual_change_signal:\n            manual_change_signal.connect(self.on_manual_change)\n\n    def sizeHint(self):\n        \"\"\"Assuming two columns in the table, return `QSize(320, 512)` as\n        a reasonable default size.\"\"\"\n        return QSize(320, 512)\n\n    def check_preconditions(self):\n        \"\"\"Refuse ranking if there are less than two feature or instances.\"\"\"\n        can_rank = self.master.data is not None and \\\n            len(self.master.data.domain.attributes) >= 2 and \\\n            len(self.master.data) >= 2\n        self.Information.nothing_to_rank(shown=not can_rank)\n        return can_rank\n\n    def on_selection_changed(self, selected, deselected):\n        selection = selected.indexes()\n        if not selection:\n            return\n        attrs = selected.indexes()[0].data(self._AttrRole)\n        self.selectionChanged.emit(attrs)\n\n    def on_manual_change(self, attr1, attr2):\n        model = self.rank_model\n        self.rank_table.selectionModel().clear()\n        for row in range(model.rowCount()):\n            a1, a2 = model.data(model.index(row, 0), self._AttrRole)\n            if a1 is attr1 and a2 is attr2:\n                self.rank_table.selectRow(row)\n                return\n\n    def state_count(self):\n        n_attrs = len(self.attrs)\n        return n_attrs * (n_attrs - 1) / 2\n\n    def iterate_states(self, initial_state):\n        si, sj = initial_state or (0, 0)\n        for i in range(si, len(self.attrs)):\n            for j in range(sj, i):\n                yield i, j\n            sj = 0\n\n    def row_for_state(self, score, state):\n        attrs = sorted((self.attrs[x] for x in state), key=attrgetter(\"name\"))\n        item = QStandardItem(\", \".join(a.name for a in attrs))\n        item.setData(attrs, self._AttrRole)\n        return [item]\n\n\nclass CanvasText(QGraphicsTextItem):\n    \"\"\"QGraphicsTextItem with more convenient constructor\n\n       Args:\n           scene (QGraphicsScene): scene into which the text is placed\n           text (str): text; see also argument `html_text` (default: `\"\"`)\n           x (int): x-coordinate (default: 0)\n           y (int): y-coordinate (default: 0)\n           alignment (Qt.Alignment): text alignment\n               (default: Qt.AlignLeft | Qt.AlignTop)\n           bold (bool): if `True`, font is set to bold (default: `False`)\n           font (QFont): text font\n           z (int): text layer\n           html_text (str): text as html; if present (default is `None`),\n               it overrides the `text` argument\n           tooltip (str): text tooltip\n           show (bool): if `False`, the text is hidden (default: `True`)\n           vertical (bool): if `True`, the text is rotated by 90 degrees\n               (default: `False`)\n    \"\"\"\n    def __init__(self, scene, text=\"\", x=0, y=0,\n                 alignment=Qt.AlignLeft | Qt.AlignTop, bold=False, font=None,\n                 z=0, html_text=None, tooltip=None, show=True, vertical=False,\n                 max_width=None):\n        QGraphicsTextItem.__init__(self, text, None)\n\n        if font:\n            self.setFont(font)\n        if bold:\n            font = self.font()\n            font.setBold(bold)\n            self.setFont(font)\n        if html_text:\n            self.setHtml(html_text)\n\n        self.alignment = alignment\n        self.vertical = vertical\n        if vertical:\n            self.setRotation(-90)\n\n        self.setPos(x, y)\n        self.x, self.y = x, y\n        self.setZValue(z)\n        if tooltip:\n            self.setToolTip(tooltip)\n        if max_width is not None:\n            assert not html_text\n            self.elide(max_width)\n\n        if show:\n            self.show()\n        else:\n            self.hide()\n\n        if scene is not None:\n            scene.addItem(self)\n\n    def elide(self, max_width):\n        if self.boundingRect().width() <= max_width:\n            return\n        short = self.toPlainText()\n        if not self.toolTip():\n            self.setToolTip(short)\n        while short and self.boundingRect().width() > max_width:\n            short = short[:-1]\n            self.setPlainText(short + \"...\")\n            # apparently this has to be called to reset position\n            self.setPos(self.x, self.y)\n\n    def setPos(self, x, y):\n        \"\"\"setPos with adjustment for alignment\"\"\"\n        self.x, self.y = x, y\n        rect = QGraphicsTextItem.boundingRect(self)\n        if self.vertical:\n            h, w = rect.height(), rect.width()\n            rect.setWidth(h)\n            rect.setHeight(-w)\n        if int(self.alignment & Qt.AlignRight):\n            x -= rect.width()\n        elif int(self.alignment & Qt.AlignHCenter):\n            x -= rect.width() / 2.\n        if int(self.alignment & Qt.AlignBottom):\n            y -= rect.height()\n        elif int(self.alignment & Qt.AlignVCenter):\n            y -= rect.height() / 2.\n        QGraphicsTextItem.setPos(self, x, y)\n\n\nclass CanvasRectangle(QGraphicsRectItem):\n    \"\"\"QGraphicsRectItem with more convenient constructor\n\n    Args:\n        scene (QGraphicsScene): scene into which the rectangle is placed\n        x (int): x-coordinate (default: 0)\n        y (int): y-coordinate (default: 0)\n        width (int): rectangle's width (default: 0)\n        height (int): rectangle's height (default: 0)\n        z (int): z-layer\n        pen (QPen): pen for the border; if present, it overrides the separate\n            arguments for color, width and style\n        pen_color (QColor or QPen): the (color of) the pen\n            (default: `QColor(128, 128, 128)`)\n        pen_width (int): pen width\n        pen_style (PenStyle): pen style (default: `Qt.SolidLine`)\n        brush_color (QColor): the color for the interior (default: same as pen)\n        tooltip (str): tooltip\n        show (bool): if `False`, the text is hidden (default: `True`)\n        onclick (callable): callback for mouse click event\n    \"\"\"\n\n    def __init__(self, scene, x=0, y=0, width=0, height=0,\n                 pen_color=QColor(128, 128, 128), brush_color=None, pen_width=1,\n                 z=0, pen_style=Qt.SolidLine, pen=None, tooltip=None, show=True,\n                 onclick=None):\n        super().__init__(x, y, width, height, None)\n        self.onclick = onclick\n        if brush_color:\n            self.setBrush(QBrush(brush_color))\n        if pen:\n            self.setPen(pen)\n        else:\n            self.setPen(QPen(QBrush(pen_color), pen_width, pen_style))\n        self.setZValue(z)\n        if tooltip:\n            self.setToolTip(tooltip)\n        if show:\n            self.show()\n        else:\n            self.hide()\n\n        if scene is not None:\n            scene.addItem(self)\n\n    def mousePressEvent(self, event):\n        if self.onclick:\n            self.onclick(self, event)\n\n\nclass ViewWithPress(QGraphicsView):\n    \"\"\"QGraphicsView with a callback for mouse press event. The callback\n    is given as keyword argument `handler`.\n    \"\"\"\n    def __init__(self, *args, **kwargs):\n        self.handler = kwargs.pop(\"handler\")\n        super().__init__(*args)\n\n    def mousePressEvent(self, event):\n        super().mousePressEvent(event)\n        if not event.isAccepted():\n            self.handler()\n",
            "header": {
                "file": {
                    "path": "Orange/widgets/visualize/utils/__init__.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "d053cf318",
                "new_commit_hash": "248839290",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/widgets/visualize/utils/__init__.py"
            },
            "plus_file": {
                "path": "b/Orange/widgets/visualize/utils/__init__.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 7,
                            "length": 6
                        },
                        "new_range": {
                            "start": 7,
                            "length": 7
                        },
                        "section": "from operator import attrgetter"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "from queue import Queue, Empty",
                                "type": "context"
                            },
                            {
                                "content": "from types import SimpleNamespace as namespace",
                                "type": "context"
                            },
                            {
                                "content": "from typing import Optional, Iterable, List, Callable",
                                "type": "context"
                            },
                            {
                                "content": "from threading import Timer",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "from AnyQt.QtCore import Qt, QSize, pyqtSignal as Signal, QSortFilterProxyModel",
                                "type": "context"
                            },
                            {
                                "content": "from AnyQt.QtGui import QStandardItemModel, QStandardItem, QColor, QBrush, QPen",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [],
                    "added_entities": [
                        {
                            "file_name": "Orange/widgets/visualize/utils/__init__.py",
                            "type": "statement",
                            "name": "",
                            "content": "from threading import Timer",
                            "ast_type_str": "ImportFrom",
                            "start_lineno": 10,
                            "end_lineno": 10,
                            "parent": null
                        }
                    ],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 393,
                            "length": 6
                        },
                        "new_range": {
                            "start": 394,
                            "length": 7
                        },
                        "section": "def run_vizrank(compute_score: Callable, iterate_states: Callable,"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "    task.set_status(\"Getting scores...\")",
                                "type": "context"
                            },
                            {
                                "content": "    res = Result(queue=Queue(), scores=None)",
                                "type": "context"
                            },
                            {
                                "content": "    scores = scores.copy()",
                                "type": "context"
                            },
                            {
                                "content": "    can_set_partial_result = True",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def do_work(st, next_st):",
                                "type": "context"
                            },
                            {
                                "content": "        try:",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/visualize/utils/__init__.py",
                            "type": "function",
                            "name": "run_vizrank",
                            "content": "def run_vizrank(compute_score: Callable, iterate_states: Callable,\n                saved_state: Optional[Iterable], scores: List,\n                progress: int, state_count: int, task: TaskState):\n    task.set_status(\"Getting combinations...\")\n    task.set_progress_value(0.1)\n    states = iterate_states(saved_state)\n\n    task.set_status(\"Getting scores...\")\n    res = Result(queue=Queue(), scores=None)\n    scores = scores.copy()\n    can_set_partial_result = True\n\n    def do_work(st, next_st):\n        try:\n            score = compute_score(st)\n            if score is not None:\n                pos = bisect_left(scores, score)\n                res.queue.put_nowait(QueuedScore(position=pos, score=score,\n                                                 state=st, next_state=next_st))\n                scores.insert(pos, score)\n        except Exception:  # ignore current state in case of any problem\n            pass\n        res.scores = scores.copy()\n\n    def reset_flag():\n        nonlocal can_set_partial_result\n        can_set_partial_result = True\n\n    state = None\n    next_state = next(states)\n    try:\n        while True:\n            if task.is_interruption_requested():\n                return res\n            task.set_progress_value(int(progress * 100 / max(1, state_count)))\n            progress += 1\n            state = copy.copy(next_state)\n            next_state = copy.copy(next(states))\n            do_work(state, next_state)\n            # for simple scores (e.g. correlations widget) and many feature\n            # combinations, the 'partial_result_ready' signal (emitted by\n            # invoking 'task.set_partial_result') was emitted too frequently\n            # for a longer period of time and therefore causing the widget\n            # being unresponsive\n            if can_set_partial_result:\n                task.set_partial_result(res)\n                can_set_partial_result = False\n                Timer(0.01, reset_flag).start()\n    except StopIteration:\n        do_work(state, None)\n        task.set_partial_result(res)\n    return res",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 387,
                            "end_lineno": 438,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 405,
                            "length": 7
                        },
                        "new_range": {
                            "start": 407,
                            "length": 10
                        },
                        "section": "def run_vizrank(compute_score: Callable, iterate_states: Callable,"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        except Exception:  # ignore current state in case of any problem",
                                "type": "context"
                            },
                            {
                                "content": "            pass",
                                "type": "context"
                            },
                            {
                                "content": "        res.scores = scores.copy()",
                                "type": "context"
                            },
                            {
                                "content": "        task.set_partial_result(res)",
                                "type": "deleted"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "    def reset_flag():",
                                "type": "added"
                            },
                            {
                                "content": "        nonlocal can_set_partial_result",
                                "type": "added"
                            },
                            {
                                "content": "        can_set_partial_result = True",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    state = None",
                                "type": "context"
                            },
                            {
                                "content": "    next_state = next(states)",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/visualize/utils/__init__.py",
                            "type": "function",
                            "name": "run_vizrank",
                            "content": "def run_vizrank(compute_score: Callable, iterate_states: Callable,\n                saved_state: Optional[Iterable], scores: List,\n                progress: int, state_count: int, task: TaskState):\n    task.set_status(\"Getting combinations...\")\n    task.set_progress_value(0.1)\n    states = iterate_states(saved_state)\n\n    task.set_status(\"Getting scores...\")\n    res = Result(queue=Queue(), scores=None)\n    scores = scores.copy()\n\n    def do_work(st, next_st):\n        try:\n            score = compute_score(st)\n            if score is not None:\n                pos = bisect_left(scores, score)\n                res.queue.put_nowait(QueuedScore(position=pos, score=score,\n                                                 state=st, next_state=next_st))\n                scores.insert(pos, score)\n        except Exception:  # ignore current state in case of any problem\n            pass\n        res.scores = scores.copy()\n        task.set_partial_result(res)\n\n    state = None\n    next_state = next(states)\n    try:\n        while True:\n            if task.is_interruption_requested():\n                return res\n            task.set_progress_value(int(progress * 100 / max(1, state_count)))\n            progress += 1\n            state = copy.copy(next_state)\n            next_state = copy.copy(next(states))\n            do_work(state, next_state)\n    except StopIteration:\n        do_work(state, None)\n    return res",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 386,
                            "end_lineno": 423,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 418,
                            "length": 8
                        },
                        "new_range": {
                            "start": 423,
                            "length": 18
                        },
                        "section": "def run_vizrank(compute_score: Callable, iterate_states: Callable,"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "            state = copy.copy(next_state)",
                                "type": "context"
                            },
                            {
                                "content": "            next_state = copy.copy(next(states))",
                                "type": "context"
                            },
                            {
                                "content": "            do_work(state, next_state)",
                                "type": "context"
                            },
                            {
                                "content": "            # for simple scores (e.g. correlations widget) and many feature",
                                "type": "added"
                            },
                            {
                                "content": "            # combinations, the 'partial_result_ready' signal (emitted by",
                                "type": "added"
                            },
                            {
                                "content": "            # invoking 'task.set_partial_result') was emitted too frequently",
                                "type": "added"
                            },
                            {
                                "content": "            # for a longer period of time and therefore causing the widget",
                                "type": "added"
                            },
                            {
                                "content": "            # being unresponsive",
                                "type": "added"
                            },
                            {
                                "content": "            if can_set_partial_result:",
                                "type": "added"
                            },
                            {
                                "content": "                task.set_partial_result(res)",
                                "type": "added"
                            },
                            {
                                "content": "                can_set_partial_result = False",
                                "type": "added"
                            },
                            {
                                "content": "                Timer(0.01, reset_flag).start()",
                                "type": "added"
                            },
                            {
                                "content": "    except StopIteration:",
                                "type": "context"
                            },
                            {
                                "content": "        do_work(state, None)",
                                "type": "context"
                            },
                            {
                                "content": "        task.set_partial_result(res)",
                                "type": "added"
                            },
                            {
                                "content": "    return res",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/visualize/utils/__init__.py",
                            "type": "function",
                            "name": "run_vizrank",
                            "content": "def run_vizrank(compute_score: Callable, iterate_states: Callable,\n                saved_state: Optional[Iterable], scores: List,\n                progress: int, state_count: int, task: TaskState):\n    task.set_status(\"Getting combinations...\")\n    task.set_progress_value(0.1)\n    states = iterate_states(saved_state)\n\n    task.set_status(\"Getting scores...\")\n    res = Result(queue=Queue(), scores=None)\n    scores = scores.copy()\n    can_set_partial_result = True\n\n    def do_work(st, next_st):\n        try:\n            score = compute_score(st)\n            if score is not None:\n                pos = bisect_left(scores, score)\n                res.queue.put_nowait(QueuedScore(position=pos, score=score,\n                                                 state=st, next_state=next_st))\n                scores.insert(pos, score)\n        except Exception:  # ignore current state in case of any problem\n            pass\n        res.scores = scores.copy()\n\n    def reset_flag():\n        nonlocal can_set_partial_result\n        can_set_partial_result = True\n\n    state = None\n    next_state = next(states)\n    try:\n        while True:\n            if task.is_interruption_requested():\n                return res\n            task.set_progress_value(int(progress * 100 / max(1, state_count)))\n            progress += 1\n            state = copy.copy(next_state)\n            next_state = copy.copy(next(states))\n            do_work(state, next_state)\n            # for simple scores (e.g. correlations widget) and many feature\n            # combinations, the 'partial_result_ready' signal (emitted by\n            # invoking 'task.set_partial_result') was emitted too frequently\n            # for a longer period of time and therefore causing the widget\n            # being unresponsive\n            if can_set_partial_result:\n                task.set_partial_result(res)\n                can_set_partial_result = False\n                Timer(0.01, reset_flag).start()\n    except StopIteration:\n        do_work(state, None)\n        task.set_partial_result(res)\n    return res",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 387,
                            "end_lineno": 438,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "7a52bc6056d940d321ee90ac114c6e44d2829803^",
    "new_commit_hash": "7a52bc6056d940d321ee90ac114c6e44d2829803",
    "commit_message": "VizRankDialog: Restrict frequency of signal emitting",
    "commit_date": "2019-09-11T11:22:54+02:00",
    "metadata": {}
}
{
    "repo_name": "orange3",
    "new_commit_hash": "7a52bc6056d940d321ee90ac114c6e44d2829803",
    "test_file_codes": [
        "from itertools import chain\nimport unittest\nfrom unittest.mock import Mock\nfrom queue import Queue\n\nfrom AnyQt.QtGui import QStandardItem\n\nfrom Orange.data import Table\nfrom Orange.widgets.visualize.utils import (\n    VizRankDialog, Result, run_vizrank, QueuedScore\n)\nfrom Orange.widgets.tests.base import WidgetTest\n\n\ndef compute_score(x):\n    return (x[0] + 1) / (x[1] + 1)\n\n\nclass TestRunner(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.data = Table(\"iris\")\n\n    def test_Result(self):\n        res = Result(queue=Queue(), scores=[])\n        self.assertIsInstance(res.queue, Queue)\n        self.assertIsInstance(res.scores, list)\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 2)\n        self.assertEqual(task.set_progress_value.call_count, 7)\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 1)\n        self.assertEqual(task.set_progress_value.call_count, 3)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        i = states.index(next_state)\n        res = run_vizrank(compute_score, lambda initial: chain(states[i:]),\n                          None, res_scores, 2, 6, task)\n\n        next_state = self.assertQueueEqual(\n            res.queue, [0, 3, 2, 5], compute_score, states[2:],\n            states[3:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n        self.assertEqual(task.set_partial_result.call_count, 3)\n        self.assertEqual(task.set_progress_value.call_count, 8)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n    def assertQueueEqual(self, queue, positions, f, states, next_states):\n        self.assertIsInstance(queue, Queue)\n        for qs in (QueuedScore(position=p, score=f(s), state=s, next_state=ns)\n                   for p, s, ns in zip(positions, states, next_states)):\n            result = queue.get_nowait()\n            self.assertEqual(result.position, qs.position)\n            self.assertEqual(result.state, qs.state)\n            self.assertEqual(result.next_state, qs.next_state)\n            self.assertEqual(result.score, qs.score)\n            next_state = result.next_state\n        return next_state\n\n\nclass TestVizRankDialog(WidgetTest):\n    def test_on_partial_result(self):\n        def iterate_states(initial_state):\n            if initial_state is not None:\n                return chain(states[states.index(initial_state):])\n            return chain(states)\n\n        def invoke_on_partial_result():\n            widget.on_partial_result(run_vizrank(\n                widget.compute_score,\n                widget.iterate_states,\n                widget.saved_state,\n                widget.scores,\n                widget.saved_progress,\n                widget.state_count(),\n                task\n            ))\n\n        task = Mock()\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n\n        widget = VizRankDialog(None)\n        widget.progressBarInit()\n        widget.compute_score = compute_score\n        widget.iterate_states = iterate_states\n        widget.row_for_state = lambda sc, _: [QStandardItem(str(sc))]\n        widget.state_count = lambda: len(states)\n\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        invoke_on_partial_result()\n        self.assertEqual(widget.rank_model.rowCount(), 2)\n        for row, score in enumerate(\n                sorted([compute_score(x) for x in states[:2]])):\n            self.assertEqual(widget.rank_model.item(row, 0).text(), str(score))\n        self.assertEqual(widget.saved_progress, 2)\n        task.set_progress_value.assert_called_with(int(1 / 6 * 100))\n\n        # continue calculation through all states\n        task.is_interruption_requested.side_effect = lambda: False\n        invoke_on_partial_result()\n        self.assertEqual(widget.rank_model.rowCount(), 6)\n        for row, score in enumerate(\n                sorted([compute_score(x) for x in states])):\n            self.assertEqual(widget.rank_model.item(row, 0).text(), str(score))\n        self.assertEqual(widget.saved_progress, 6)\n        task.set_progress_value.assert_called_with(int(5 / 6 * 100))\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n"
    ],
    "test_file_names": [
        "test_1.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "Starting Orange installation attempts...\nAttempting installation with Python 3.7...\nWarning: 'keywords' should be a list, got type 'tuple'\nWarning: 'classifiers' should be a list, got type 'tuple'\nWarning: 'keywords' should be a list, got type 'tuple'\nWarning: 'classifiers' should be a list, got type 'tuple'\nrunning build_ext\nrunning build_src\nbuild_src\nbuilding extension \"Orange.classification._simple_tree\" sources\nbuilding extension \"Orange.classification._tree_scorers\" sources\nbuilding extension \"Orange.data._valuecount\" sources\nbuilding extension \"Orange.data._contingency\" sources\nbuilding extension \"Orange.data._io\" sources\nbuilding extension \"Orange.data._variable\" sources\nbuilding extension \"Orange.distance._distance\" sources\nbuilding extension \"Orange.preprocess._discretize\" sources\nbuilding extension \"Orange.preprocess._relieff\" sources\nbuilding extension \"Orange.projection._som\" sources\nbuilding extension \"Orange.widgets.utils._grid_density\" sources\nbuild_src: building npy-pkg config files\ncustomize UnixCCompiler\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating /tmp/tmpzlgmergh/tmp\ncreating /tmp/tmpzlgmergh/tmp/tmpzlgmergh\ncompile options: '-MMD -MF /tmp/tmpzlgmergh/file.c.d -c'\ncc: /tmp/tmpzlgmergh/file.c\ncustomize UnixCCompiler using build_ext\ncustomize UnixCCompiler\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating /tmp/tmp5c8_cqjj/tmp\ncreating /tmp/tmp5c8_cqjj/tmp/tmp5c8_cqjj\ncompile options: '-MMD -MF /tmp/tmp5c8_cqjj/file.c.d -c'\ncc: /tmp/tmp5c8_cqjj/file.c\ncustomize UnixCCompiler using build_ext\nbuilding 'Orange.classification._simple_tree' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating build/temp.linux-x86_64-3.7/Orange\ncreating build/temp.linux-x86_64-3.7/Orange/classification\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/classification/_simple_tree.c\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/classification/_simple_tree.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.classification._tree_scorers' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/classification/_tree_scorers.c\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/classification/_tree_scorers.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._valuecount' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating build/temp.linux-x86_64-3.7/Orange/data\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/data/_valuecount.c\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_valuecount.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._contingency' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/data/_contingency.c\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_contingency.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._io' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/data/_io.c\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_io.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o Orange/data/_io.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._variable' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/data/_variable.c\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_variable.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.distance._distance' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating build/temp.linux-x86_64-3.7/Orange/distance\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/distance/_distance.c\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/distance/_distance.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._discretize' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating build/temp.linux-x86_64-3.7/Orange/preprocess\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/preprocess/_discretize.c\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/preprocess/_discretize.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._relieff' extension\ncompiling C++ sources\nC compiler: c++ -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\nc++: Orange/preprocess/_relieff.cpp\nc++ -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/preprocess/_relieff.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.projection._som' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating build/temp.linux-x86_64-3.7/Orange/projection\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/projection/_som.c\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/projection/_som.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.widgets.utils._grid_density' extension\ncompiling C++ sources\nC compiler: c++ -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating build/temp.linux-x86_64-3.7/Orange/widgets\ncreating build/temp.linux-x86_64-3.7/Orange/widgets/utils\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\nc++: Orange/widgets/utils/_grid_density.cpp\nc++ -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so\nWarning: 'keywords' should be a list, got type 'tuple'\nWarning: 'classifiers' should be a list, got type 'tuple'\nWarning: 'keywords' should be a list, got type 'tuple'\nWarning: 'classifiers' should be a list, got type 'tuple'\nrunning develop\nrunning build_scripts\nrunning egg_info\nrunning build_src\nbuild_src\nbuilding extension \"Orange.classification._simple_tree\" sources\nbuilding extension \"Orange.classification._tree_scorers\" sources\nbuilding extension \"Orange.data._valuecount\" sources\nbuilding extension \"Orange.data._contingency\" sources\nbuilding extension \"Orange.data._io\" sources\nbuilding extension \"Orange.data._variable\" sources\nbuilding extension \"Orange.distance._distance\" sources\nbuilding extension \"Orange.preprocess._discretize\" sources\nbuilding extension \"Orange.preprocess._relieff\" sources\nbuilding extension \"Orange.projection._som\" sources\nbuilding extension \"Orange.widgets.utils._grid_density\" sources\nbuild_src: building npy-pkg config files\ncreating Orange3.egg-info\nwriting Orange3.egg-info/PKG-INFO\nwriting dependency_links to Orange3.egg-info/dependency_links.txt\nwriting entry points to Orange3.egg-info/entry_points.txt\nwriting requirements to Orange3.egg-info/requires.txt\nwriting top-level names to Orange3.egg-info/top_level.txt\nwriting manifest file 'Orange3.egg-info/SOURCES.txt'\nreading manifest file 'Orange3.egg-info/SOURCES.txt'\nreading manifest template 'MANIFEST.in'\nwarning: no files found matching 'README*' under directory 'Orange'\nwarning: no files found matching 'LICENSE' under directory 'Orange'\nwarning: no files found matching '*.basket' under directory 'Orange/datasets'\nwarning: no files found matching '*.js' under directory 'Orange/widgets'\nwarning: no files found matching '*.css' under directory 'Orange/widgets'\nwarning: no files found matching '*.html' under directory 'Orange/widgets'\nwarning: no files found matching 'COPYING'\nadding license file 'LICENSE'\nwriting manifest file 'Orange3.egg-info/SOURCES.txt'\nrunning build_ext\ncustomize UnixCCompiler\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating /tmp/tmpgt4ouqf6/tmp\ncreating /tmp/tmpgt4ouqf6/tmp/tmpgt4ouqf6\ncompile options: '-MMD -MF /tmp/tmpgt4ouqf6/file.c.d -c'\ncc: /tmp/tmpgt4ouqf6/file.c\ncustomize UnixCCompiler using build_ext\ncustomize UnixCCompiler\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating /tmp/tmpv60_srtc/tmp\ncreating /tmp/tmpv60_srtc/tmp/tmpv60_srtc\ncompile options: '-MMD -MF /tmp/tmpv60_srtc/file.c.d -c'\ncc: /tmp/tmpv60_srtc/file.c\ncustomize UnixCCompiler using build_ext\nCreating /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/Orange3.egg-link (link to .)\nAdding Orange3 3.24.0.dev0+7a52bc6 to easy-install.pth file\nInstalling orange-canvas script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\n\nInstalled /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803\nProcessing dependencies for Orange3==3.24.0.dev0+7a52bc6\nSearching for XlsxWriter==3.2.0\nBest match: XlsxWriter 3.2.0\nAdding XlsxWriter 3.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for xlrd==2.0.1\nBest match: xlrd 2.0.1\nAdding xlrd 2.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for setuptools==59.8.0\nBest match: setuptools 59.8.0\nAdding setuptools 59.8.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for serverfiles==0.3.1\nBest match: serverfiles 0.3.1\nAdding serverfiles 0.3.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for scipy==1.7.3\nBest match: scipy 1.7.3\nAdding scipy 1.7.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for scikit-learn==1.0.2\nBest match: scikit-learn 1.0.2\nAdding scikit-learn 1.0.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for requests==2.31.0\nBest match: requests 2.31.0\nAdding requests 2.31.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for PyYAML==6.0.1\nBest match: PyYAML 6.0.1\nAdding PyYAML 6.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for python-louvain==0.16\nBest match: python-louvain 0.16\nAdding python-louvain 0.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for pyqtgraph==0.12.4\nBest match: pyqtgraph 0.12.4\nAdding pyqtgraph 0.12.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for pip==24.0\nBest match: pip 24.0\nAdding pip 24.0 to easy-install.pth file\nInstalling pip script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\nInstalling pip3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\nInstalling pip3.10 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for pandas==1.3.5\nBest match: pandas 1.3.5\nAdding pandas 1.3.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for orange-widget-base==4.0.1\nBest match: orange-widget-base 4.0.1\nAdding orange-widget-base 4.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for orange-canvas-core==0.1.35\nBest match: orange-canvas-core 0.1.35\nAdding orange-canvas-core 0.1.35 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for openTSNE==1.0.1\nBest match: openTSNE 1.0.1\nAdding openTSNE 1.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for numpy==1.17.5\nBest match: numpy 1.17.5\nAdding numpy 1.17.5 to easy-install.pth file\nInstalling f2py script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\nInstalling f2py3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\nInstalling f2py3.7 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for networkx==2.6.3\nBest match: networkx 2.6.3\nAdding networkx 2.6.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for matplotlib==3.5.3\nBest match: matplotlib 3.5.3\nAdding matplotlib 3.5.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for keyrings.alt==4.2.0\nBest match: keyrings.alt 4.2.0\nAdding keyrings.alt 4.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for keyring==24.1.1\nBest match: keyring 24.1.1\nAdding keyring 24.1.1 to easy-install.pth file\nInstalling keyring script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for joblib==1.3.2\nBest match: joblib 1.3.2\nAdding joblib 1.3.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for docutils==0.20.1\nBest match: docutils 0.20.1\nAdding docutils 0.20.1 to easy-install.pth file\nInstalling docutils script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for chardet==5.2.0\nBest match: chardet 5.2.0\nAdding chardet 5.2.0 to easy-install.pth file\nInstalling chardetect script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for Bottleneck==1.4.0\nBest match: Bottleneck 1.4.0\nAdding Bottleneck 1.4.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for AnyQt==0.2.0\nBest match: AnyQt 0.2.0\nAdding AnyQt 0.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for threadpoolctl==3.1.0\nBest match: threadpoolctl 3.1.0\nAdding threadpoolctl 3.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for urllib3==2.0.7\nBest match: urllib3 2.0.7\nAdding urllib3 2.0.7 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for certifi==2024.12.14\nBest match: certifi 2024.12.14\nAdding certifi 2024.12.14 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for idna==3.10\nBest match: idna 3.10\nAdding idna 3.10 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for charset-normalizer==3.4.1\nBest match: charset-normalizer 3.4.1\nAdding charset-normalizer 3.4.1 to easy-install.pth file\nInstalling normalizer script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for pytz==2024.2\nBest match: pytz 2024.2\nAdding pytz 2024.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for python-dateutil==2.9.0.post0\nBest match: python-dateutil 2.9.0.post0\nAdding python-dateutil 2.9.0.post0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for requests-cache==1.1.1\nBest match: requests-cache 1.1.1\nAdding requests-cache 1.1.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for commonmark==0.9.1\nBest match: commonmark 0.9.1\nAdding commonmark 0.9.1 to easy-install.pth file\nInstalling cmark script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for dictdiffer==0.9.0\nBest match: dictdiffer 0.9.0\nAdding dictdiffer 0.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for importlib-metadata==6.7.0\nBest match: importlib-metadata 6.7.0\nAdding importlib-metadata 6.7.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for qasync==0.25.0\nBest match: qasync 0.25.0\nAdding qasync 0.25.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for packaging==24.0\nBest match: packaging 24.0\nAdding packaging 24.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for cycler==0.11.0\nBest match: cycler 0.11.0\nAdding cycler 0.11.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for fonttools==4.38.0\nBest match: fonttools 4.38.0\nAdding fonttools 4.38.0 to easy-install.pth file\nInstalling fonttools script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\nInstalling pyftmerge script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\nInstalling pyftsubset script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\nInstalling ttx script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for kiwisolver==1.4.5\nBest match: kiwisolver 1.4.5\nAdding kiwisolver 1.4.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for Pillow==9.5.0\nBest match: Pillow 9.5.0\nAdding Pillow 9.5.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for pyparsing==3.1.4\nBest match: pyparsing 3.1.4\nAdding pyparsing 3.1.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for jaraco.classes==3.2.3\nBest match: jaraco.classes 3.2.3\nAdding jaraco.classes 3.2.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for importlib-resources==5.12.0\nBest match: importlib-resources 5.12.0\nAdding importlib-resources 5.12.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for jeepney==0.8.0\nBest match: jeepney 0.8.0\nAdding jeepney 0.8.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for SecretStorage==3.3.3\nBest match: SecretStorage 3.3.3\nAdding SecretStorage 3.3.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for six==1.17.0\nBest match: six 1.17.0\nAdding six 1.17.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for attrs==24.2.0\nBest match: attrs 24.2.0\nAdding attrs 24.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for platformdirs==4.0.0\nBest match: platformdirs 4.0.0\nAdding platformdirs 4.0.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for cattrs==23.1.2\nBest match: cattrs 23.1.2\nAdding cattrs 23.1.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for url-normalize==1.4.3\nBest match: url-normalize 1.4.3\nAdding url-normalize 1.4.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for typing-extensions==4.7.1\nBest match: typing-extensions 4.7.1\nAdding typing-extensions 4.7.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for zipp==3.15.0\nBest match: zipp 3.15.0\nAdding zipp 3.15.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for more-itertools==9.1.0\nBest match: more-itertools 9.1.0\nAdding more-itertools 9.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for cryptography==44.0.0\nBest match: cryptography 44.0.0\nAdding cryptography 44.0.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for exceptiongroup==1.2.2\nBest match: exceptiongroup 1.2.2\nAdding exceptiongroup 1.2.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for cffi==1.15.1\nBest match: cffi 1.15.1\nAdding cffi 1.15.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nSearching for pycparser==2.21\nBest match: pycparser 2.21\nAdding pycparser 2.21 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages\nFinished processing dependencies for Orange3==3.24.0.dev0+7a52bc6\nVerifying Orange installation...\n✅ Orange installation successful!\nSuccessfully installed orange using Python 3.7\n",
    "setup_res_stderr": "Using CPython 3.7.9\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 18 packages in 56ms\nPrepared 18 packages in 9ms\nInstalled 18 packages in 264ms\n + cython==0.29.37\n + exceptiongroup==1.2.2\n + importlib-metadata==6.7.0\n + iniconfig==2.0.0\n + numpy==1.17.5\n + packaging==24.0\n + pluggy==1.2.0\n + pyqt5==5.15.10\n + pyqt5-qt5==5.15.16\n + pyqt5-sip==12.13.0\n + pyqtwebengine==5.15.6\n + pyqtwebengine-qt5==5.15.16\n + pytest==7.4.4\n + setuptools==59.8.0\n + tomli==2.0.1\n + typing-extensions==4.7.1\n + wheel==0.42.0\n + zipp==3.15.0\nResolved 38 packages in 203ms\nInstalled 33 packages in 654ms\n + bottleneck==1.4.0\n + certifi==2024.12.14\n + cffi==1.15.1\n + chardet==5.2.0\n + charset-normalizer==3.4.1\n + cryptography==44.0.0\n + idna==3.10\n + importlib-resources==5.12.0\n + jaraco-classes==3.2.3\n + jeepney==0.8.0\n + joblib==1.3.2\n + keyring==24.1.1\n + keyrings-alt==4.2.0\n + more-itertools==9.1.0\n + networkx==2.6.3\n + opentsne==1.0.1\n + pandas==1.3.5\n + pip==24.0\n + pycparser==2.21\n + python-dateutil==2.9.0.post0\n + python-louvain==0.16\n + pytz==2024.2\n + pyyaml==6.0.1\n + requests==2.31.0\n + scikit-learn==1.0.2\n + scipy==1.7.3\n + secretstorage==3.3.3\n + serverfiles==0.3.1\n + six==1.17.0\n + threadpoolctl==3.1.0\n + urllib3==2.0.7\n + xlrd==2.0.1\n + xlsxwriter==3.2.0\nResolved 34 packages in 142ms\nInstalled 19 packages in 132ms\n + anyqt==0.2.0\n + attrs==24.2.0\n + cattrs==23.1.2\n + commonmark==0.9.1\n + cycler==0.11.0\n + dictdiffer==0.9.0\n + docutils==0.20.1\n + fonttools==4.38.0\n + kiwisolver==1.4.5\n + matplotlib==3.5.3\n + orange-canvas-core==0.1.35\n + orange-widget-base==4.0.1\n + pillow==9.5.0\n + platformdirs==4.0.0\n + pyparsing==3.1.4\n + pyqtgraph==0.12.4\n + qasync==0.25.0\n + requests-cache==1.1.1\n + url-normalize==1.4.3\nResolved 2 packages in 4ms\nInstalled 2 packages in 36ms\n + psycopg2==2.9.9\n + pymssql==2.3.2\nAudited 1 package in 1ms\nAudited 2 packages in 22ms\nOrange/classification/_simple_tree.c: In function ‘gain_ratio_c’:\nOrange/classification/_simple_tree.c:63:9: warning: implicit declaration of function ‘qsort_r’; did you mean ‘qsort’? [-Wimplicit-function-declaration]\n   63 |         qsort_r(base, nel, size, compar, thunk)\n      |         ^~~~~~~\nOrange/classification/_simple_tree.c:147:9: note: in expansion of macro ‘QSORT_R_FUNC’\n  147 |         QSORT_R_FUNC(examples, size, sizeof(struct Example), (void*) &compar_attr, compar_examples);\n      |         ^~~~~~~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/classification/_tree_scorers.c:567:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_2find_threshold_entropy’:\nOrange/classification/_tree_scorers.c:3115:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 3115 |   __pyx_t_7 = ((__pyx_v_N <= __pyx_v_min_leaf) != 0);\n      |                           ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_6find_threshold_MSE’:\nOrange/classification/_tree_scorers.c:4619:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 4619 |   __pyx_t_1 = ((__pyx_v_N <= __pyx_v_min_leaf) != 0);\n      |                           ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_8find_binarization_MSE’:\nOrange/classification/_tree_scorers.c:5396:43: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5396 |           for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {\n      |                                           ^\nOrange/classification/_tree_scorers.c:5517:39: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5517 |           __pyx_t_27 = ((__pyx_v_left >= __pyx_v_min_leaf) != 0);\n      |                                       ^~\nOrange/classification/_tree_scorers.c:5523:53: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5523 |           __pyx_t_27 = (((__pyx_v_N - __pyx_v_left) >= __pyx_v_min_leaf) != 0);\n      |                                                     ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_14compute_predictions_csr’:\nOrange/classification/_tree_scorers.c:7051:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7051 |         for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_16compute_predictions_csc’:\nOrange/classification/_tree_scorers.c:7741:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7741 |         for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c:7801:143: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int32_t’ {aka ‘int’} and ‘unsigned int’ [-Wsign-compare]\n 7801 |               __pyx_t_17 = (((*((__pyx_t_5numpy_int32_t *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_18 * __pyx_v_indices.strides[0]) ))) != __pyx_v_i) != 0);\n      |                                                                                                                                               ^~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_valuecount.c:567:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_contingency.c:567:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/data/_io.c: In function ‘__pyx_pf_6Orange_4data_3_io_sparse_read_float.constprop’:\nOrange/data/_io.c:3881:24: warning: ‘__pyx_v_decs’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3881 |           __pyx_v_decs = (__pyx_v_decs / 10.0);\n      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:4070:24: warning: ‘__pyx_v_value’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4070 |           __pyx_t_10 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 221, __pyx_L5_error)\n      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:480:40: warning: ‘__pyx_v_attr_index’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n  480 |   #define PyInt_FromLong               PyLong_FromLong\n      |                                        ^~~~~~~~~~~~~~~\nOrange/data/_io.c:1301:7: note: ‘__pyx_v_attr_index’ was declared here\n 1301 |   int __pyx_v_attr_index;\n      |       ^~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:2935:25: warning: ‘__pyx_v_atomp’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 2935 |           __pyx_v_atomp = (__pyx_v_atomp + 1);\n      |           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/distance/_distance.c:567:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_discretize.c:567:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_relieff.cpp:581:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/projection/_som.c:598:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_5update_hex’:\nOrange/projection/_som.c:3655:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3655 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:3654:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3654 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_7get_winners_sparse’:\nOrange/projection/_som.c:4547:223: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4547 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_39, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_y;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:4114:7: note: ‘__pyx_v_win_y’ was declared here\n 4114 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:4536:223: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4536 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_37, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_x;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:4113:7: note: ‘__pyx_v_win_x’ was declared here\n 4113 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pf_6Orange_10projection_4_som_8update_sparse.constprop’:\nOrange/projection/_som.c:4746:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4746 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:4745:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4745 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_3update’:\nOrange/projection/_som.c:3141:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3141 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_1get_winners’:\nOrange/projection/_som.c:2964:223: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 2964 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_y;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:2665:7: note: ‘__pyx_v_win_y’ was declared here\n 2665 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:2953:223: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 2953 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_x;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:2664:7: note: ‘__pyx_v_win_x’ was declared here\n 2664 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pf_6Orange_10projection_4_som_10update_sparse_hex.constprop’:\nOrange/projection/_som.c:5515:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 5515 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:5514:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 5514 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.\n  setuptools.SetuptoolsDeprecationWarning,\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/setuptools/command/easy_install.py:159: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.\n  EasyInstallDeprecationWarning,\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.\n  setuptools.SetuptoolsDeprecationWarning,\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803/.venv/lib/python3.7/site-packages/setuptools/command/egg_info.py:628: SetuptoolsDeprecationWarning: Custom 'build_py' does not implement 'get_data_files_without_manifest'.\nPlease extend command classes from setuptools instead of distutils.\n  SetuptoolsDeprecationWarning\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803\ncollected 8 items\n\nr2e_tests/test_1.py ss...ss.                                             [100%]\n\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestRunner::test_Result\nPASSED r2e_tests/test_1.py::TestRunner::test_run_vizrank\nPASSED r2e_tests/test_1.py::TestRunner::test_run_vizrank_interrupt\nPASSED r2e_tests/test_1.py::TestVizRankDialog::test_on_partial_result\nSKIPPED [2] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:86: minimum size not tested as .widget was not set\nSKIPPED [2] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:92: msg base class not tested as .widget was not set\n========================= 4 passed, 4 skipped in 2.61s =========================\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_7a52bc6056d940d321ee90ac114c6e44d2829803\ncollected 8 items\n\nr2e_tests/test_1.py ss.FFss.                                             [100%]\n\n=================================== FAILURES ===================================\n_________________________ TestRunner.test_run_vizrank __________________________\n\nself = <r2e_tests.test_1.TestRunner testMethod=test_run_vizrank>\n\n    def test_run_vizrank(self):\n        scores, task = [], Mock()\n        # run through all states\n        task.is_interruption_requested.return_value = False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n    \n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0, 0, 3, 2, 5], compute_score,\n            states, states[1:] + [None])\n        self.assertIsNone(next_state)\n        res_scores = sorted([compute_score(x) for x in states])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n>       self.assertEqual(task.set_partial_result.call_count, 2)\nE       AssertionError: 6 != 2\n\nr2e_tests/test_1.py:44: AssertionError\n____________________ TestRunner.test_run_vizrank_interrupt _____________________\n\nself = <r2e_tests.test_1.TestRunner testMethod=test_run_vizrank_interrupt>\n\n    def test_run_vizrank_interrupt(self):\n        scores, task = [], Mock()\n        # interrupt calculation in third iteration\n        task.is_interruption_requested.side_effect = lambda: \\\n            True if task.is_interruption_requested.call_count > 2 else False\n        states = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n        res = run_vizrank(compute_score, lambda initial: chain(states),\n                          None, scores, 0, 6, task)\n    \n        next_state = self.assertQueueEqual(\n            res.queue, [0, 0], compute_score, states[:2], states[1:3])\n        self.assertEqual(next_state, (0, 3))\n        res_scores = sorted([compute_score(x) for x in states[:2]])\n        self.assertListEqual(res.scores, res_scores)\n        self.assertIsNot(scores, res.scores)\n>       self.assertEqual(task.set_partial_result.call_count, 1)\nE       AssertionError: 2 != 1\n\nr2e_tests/test_1.py:62: AssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestRunner::test_Result\nPASSED r2e_tests/test_1.py::TestVizRankDialog::test_on_partial_result\nSKIPPED [2] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:86: minimum size not tested as .widget was not set\nSKIPPED [2] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:92: msg base class not tested as .widget was not set\nFAILED r2e_tests/test_1.py::TestRunner::test_run_vizrank - AssertionError: 6 ...\nFAILED r2e_tests/test_1.py::TestRunner::test_run_vizrank_interrupt - Assertio...\n==================== 2 failed, 2 passed, 4 skipped in 2.13s ====================\n",
    "old_commit_res_stderr": ""
}
Orange/widgets/visualize/tests/test_vizrankdialog.py Orange/widgets/visualize/utils/__init__.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]

**Title:** VizRankDialog Emits Signals Too Frequently, Causing UI Unresponsiveness

**Description:**

In the `VizRankDialog` component, the method `task.set_partial_result(res)` is being invoked excessively during the visualization ranking process. Specifically, when dealing with simple scores (e.g., correlations widget) and a large number of feature combinations, the `'partial_result_ready'` signal is emitted too frequently. This high frequency of signal emissions leads to the widget becoming unresponsive.

**Example Buggy Code:**

```python
def run_vizrank(compute_score, iterate_states, ...):
    # ... setup code ...
    for state in states:
        do_work(state)
        task.set_partial_result(res)  # Called too often
    return res
```

**Expected Behavior:**

The `task.set_partial_result(res)` method should be called at a controlled rate to limit the frequency of `'partial_result_ready'` signal emissions. This ensures that the UI remains responsive, even when processing numerous feature combinations with simple scoring functions.

**Actual Behavior:**

The `task.set_partial_result(res)` method is called excessively (e.g., 6 times instead of the expected 2), causing the `'partial_result_ready'` signal to be emitted too frequently. This results in the widget becoming unresponsive due to the overwhelming number of signal emissions.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### Orange/widgets/visualize/utils/__init__.py
"""
Utility classes for visualization widgets
"""
import copy
from bisect import bisect_left
from operator import attrgetter
from queue import Queue, Empty
from types import SimpleNamespace as namespace
from typing import Optional, Iterable, List, Callable

from AnyQt.QtCore import Qt, QSize, pyqtSignal as Signal, QSortFilterProxyModel
from AnyQt.QtGui import QStandardItemModel, QStandardItem, QColor, QBrush, QPen
from AnyQt.QtWidgets import (
    QTableView, QGraphicsTextItem, QGraphicsRectItem, QGraphicsView, QDialog,
    QVBoxLayout, QLineEdit
)
from Orange.data import Variable
from Orange.widgets import gui
from Orange.widgets.gui import HorizontalGridDelegate, TableBarItem
from Orange.widgets.utils.concurrent import ConcurrentMixin, TaskState
from Orange.widgets.utils.messages import WidgetMessagesMixin
from Orange.widgets.utils.progressbar import ProgressBarMixin
from Orange.widgets.widget import Msg


class Result(namespace):
    queue = None  # type: Queue[QueuedScore, ...]
    scores = None  # type: Optional[List[float, ...]]


class QueuedScore(namespace):
    position = None  # type: int
    score = None  # type: float
    state = None  # type: Iterable
    next_state = None  # type: Iterable


class VizRankDialog(QDialog, ProgressBarMixin, WidgetMessagesMixin,
                    ConcurrentMixin):
    """
    Base class for VizRank dialogs, providing a GUI with a table and a button,
    and the skeleton for managing the evaluation of visualizations.

    Derived classes must provide methods

    - `iterate_states` for generating combinations (e.g. pairs of attritutes),
    - `compute_score(state)` for computing the score of a combination,
    - `row_for_state(state)` that returns a list of items inserted into the
       table for the given state.

    and, optionally,

    - `state_count` that returns the number of combinations (used for progress
       bar)
    - `on_selection_changed` that handles event triggered when the user selects
      a table row. The method should emit signal
      `VizRankDialog.selectionChanged(object)`.
    - `bar_length` returns the length of the bar corresponding to the score.

    The class provides a table and a button. A widget constructs a single
    instance of this dialog in its `__init__`, like (in Sieve) by using a
    convenience method :obj:`add_vizrank`::

        self.vizrank, self.vizrank_button = SieveRank.add_vizrank(
            box, self, "Score Combinations", self.set_attr)

    When the widget receives new data, it must call the VizRankDialog's
    method :obj:`VizRankDialog.initialize()` to clear the GUI and reset the
    state.

    Clicking the Start button calls method `run` (and renames the button to
    Pause). Run sets up a progress bar by getting the number of combinations
    from :obj:`VizRankDialog.state_count()`. It restores the paused state
    (if any) and calls generator :obj:`VizRankDialog.iterate_states()`. For
    each generated state, it calls :obj:`VizRankDialog.score(state)`, which
    must return the score (lower is better) for this state. If the returned
    state is not `None`, the data returned by `row_for_state` is inserted at
    the appropriate place in the table.

    Args:
        master (Orange.widget.OWWidget): widget to which the dialog belongs

    Attributes:
        master (Orange.widget.OWWidget): widget to which the dialog belongs
        captionTitle (str): the caption for the dialog. This can be a class
          attribute. `captionTitle` is used by the `ProgressBarMixin`.
    """

    captionTitle = ""

    NEGATIVE_COLOR = QColor(70, 190, 250)
    POSITIVE_COLOR = QColor(170, 242, 43)

    processingStateChanged = Signal(int)
    progressBarValueChanged = Signal(float)
    messageActivated = Signal(Msg)
    messageDeactivated = Signal(Msg)
    selectionChanged = Signal(object)

    class Information(WidgetMessagesMixin.Information):
        nothing_to_rank = Msg("There is nothing to rank.")

    def __init__(self, master):
        """Initialize the attributes and set up the interface"""
        QDialog.__init__(self, master, windowTitle=self.captionTitle)
        WidgetMessagesMixin.__init__(self)
        ConcurrentMixin.__init__(self)
        self.setLayout(QVBoxLayout())

        self.insert_message_bar()
        self.layout().insertWidget(0, self.message_bar)
        self.master = master

        self.keep_running = False
        self.scheduled_call = None
        self.saved_state = None
        self.saved_progress = 0
        self.scores = []
        self.add_to_model = Queue()

        self.filter = QLineEdit()
        self.filter.setPlaceholderText("Filter ...")
        self.filter.textChanged.connect(self.filter_changed)
        self.layout().addWidget(self.filter)
        # Remove focus from line edit
        self.setFocus(Qt.ActiveWindowFocusReason)

        self.rank_model = QStandardItemModel(self)
        self.model_proxy = QSortFilterProxyModel(
            self, filterCaseSensitivity=False)
        self.model_proxy.setSourceModel(self.rank_model)
        self.rank_table = view = QTableView(
            selectionBehavior=QTableView.SelectRows,
            selectionMode=QTableView.SingleSelection,
            showGrid=False,
            editTriggers=gui.TableView.NoEditTriggers)
        if self._has_bars:
            view.setItemDelegate(TableBarItem())
        else:
            view.setItemDelegate(HorizontalGridDelegate())
        view.setModel(self.model_proxy)
        view.selectionModel().selectionChanged.connect(
            self.on_selection_changed)
        view.horizontalHeader().setStretchLastSection(True)
        view.horizontalHeader().hide()
        self.layout().addWidget(view)

        self.button = gui.button(
            self, self, "Start", callback=self.toggle, default=True)

    @property
    def _has_bars(self):
        return type(self).bar_length is not VizRankDialog.bar_length

    @classmethod
    def add_vizrank(cls, widget, master, button_label, set_attr_callback):
        """
        Equip the widget with VizRank button and dialog, and monkey patch the
        widget's `closeEvent` and `hideEvent` to close/hide the vizrank, too.

        Args:
            widget (QWidget): the widget into whose layout to insert the button
            master (Orange.widgets.widget.OWWidget): the master widget
            button_label: the label for the button
            set_attr_callback: the callback for setting the projection chosen
                in the vizrank

        Returns:
            tuple with Vizrank dialog instance and push button
        """
        # Monkey patching could be avoided by mixing-in the class (not
        # necessarily a good idea since we can make a mess of multiple
        # defined/derived closeEvent and hideEvent methods). Furthermore,
        # per-class patching would be better than per-instance, but we don't
        # want to mess with meta-classes either.

        vizrank = cls(master)
        button = gui.button(
            widget, master, button_label, callback=vizrank.reshow,
            enabled=False)
        vizrank.selectionChanged.connect(lambda args: set_attr_callback(*args))

        master_close_event = master.closeEvent
        master_hide_event = master.hideEvent
        master_delete_event = master.onDeleteWidget

        def closeEvent(event):
            vizrank.close()
            master_close_event(event)

        def hideEvent(event):
            vizrank.hide()
            master_hide_event(event)

        def deleteEvent():
            vizrank.keep_running = False
            vizrank.shutdown()
            master_delete_event()

        master.closeEvent = closeEvent
        master.hideEvent = hideEvent
        master.onDeleteWidget = deleteEvent
        return vizrank, button

    def reshow(self):
        """Put the widget on top of all windows
        """
        self.show()
        self.raise_()
        self.activateWindow()

    def initialize(self):
        """
        Clear and initialize the dialog.

        This method must be called by the widget when the data is reset,
        e.g. from `set_data` handler.
        """
        if self.task is not None:
            self.keep_running = False
            self.cancel()
        self.keep_running = False
        self.scheduled_call = None
        self.saved_state = None
        self.saved_progress = 0
        self.progressBarFinished()
        self.scores = []
        self._update_model()  # empty queue
        self.rank_model.clear()
        self.button.setText("Start")
        self.button.setEnabled(self.check_preconditions())

    def filter_changed(self, text):
        self.model_proxy.setFilterFixedString(text)

    def stop_and_reset(self, reset_method=None):
        if self.keep_running:
            self.scheduled_call = reset_method or self.initialize
            self.keep_running = False
        else:
            self.initialize()

    def check_preconditions(self):
        """Check whether there is sufficient data for ranking."""
        return True

    def on_selection_changed(self, selected, deselected):
        """
        Set the new visualization in the widget when the user select a
        row in the table.

        If derived class does not reimplement this, the table gives the
        information but the user can't click it to select the visualization.

        Args:
            selected: the index of the selected item
            deselected: the index of the previously selected item
        """
        pass

    def iterate_states(self, initial_state):
        """
        Generate all possible states (e.g. attribute combinations) for the
        given data. The content of the generated states is specific to the
        visualization.

        This method must be defined in the derived classes.

        Args:
            initial_state: initial state; None if this is the first call
        """
        raise NotImplementedError

    def state_count(self):
        """
        Return the number of states for the progress bar.

        Derived classes should implement this to ensure the proper behaviour of
        the progress bar"""
        return 0

    def compute_score(self, state):
        """
        Abstract method for computing the score for the given state. Smaller
        scores are better.

        Args:
            state: the state, e.g. the combination of attributes as generated
                by :obj:`state_count`.
        """
        raise NotImplementedError

    def bar_length(self, score):
        """Compute the bar length (between 0 and 1) corresponding to the score.
        Return `None` if the score cannot be normalized.
        """
        return None

    def row_for_state(self, score, state):
        """
        Abstract method that return the items that are inserted into the table.

        Args:
            score: score, computed by :obj:`compute_score`
            state: the state, e.g. combination of attributes
            """
        raise NotImplementedError

    def _select_first_if_none(self):
        if not self.rank_table.selectedIndexes():
            self.rank_table.selectRow(0)

    def on_partial_result(self, result: Result):
        try:
            while True:
                queued = result.queue.get_nowait()
                self.saved_state = queued.next_state
                self.add_to_model.put_nowait(queued)
        except Empty:
            pass
        self.scores = result.scores
        self.saved_progress = len(self.scores)
        self._update()

    def on_done(self, result: Result):
        self.button.setText("Finished")
        self.button.setEnabled(False)
        self.keep_running = False
        self.saved_state = None
        self._stopped()

    def _stopped(self):
        self.progressBarFinished()
        self._update_model()
        self.stopped()
        if self.scheduled_call:
            self.scheduled_call()
        self._select_first_if_none()

    def _update(self):
        self._update_model()
        self._update_progress()

    def _update_progress(self):
        self.progressBarSet(int(self.saved_progress * 100 / max(1, self.state_count())))

    def _update_model(self):
        try:
            while True:
                queued = self.add_to_model.get_nowait()
                row_items = self.row_for_state(queued.score, queued.state)
                bar_length = self.bar_length(queued.score)
                if bar_length is not None:
                    row_items[0].setData(bar_length,
                                         gui.TableBarItem.BarRole)
                self.rank_model.insertRow(queued.position, row_items)
        except Empty:
            pass

    def toggle(self):
        """Start or pause the computation."""
        self.keep_running = not self.keep_running
        if self.keep_running:
            self.button.setText("Pause")
            self.button.repaint()
            self.progressBarInit()
            self.before_running()
            self.start(run_vizrank, self.compute_score,
                       self.iterate_states, self.saved_state, self.scores,
                       self.saved_progress, self.state_count())
        else:
            self.button.setText("Continue")
            self.button.repaint()
            self.cancel()
            self._stopped()

    def before_running(self):
        """Code that is run before running vizrank in its own thread"""
        pass

    def stopped(self):
        """Code that is run after stopping the vizrank thread"""
        pass


def run_vizrank(compute_score: Callable, iterate_states: Callable,
                saved_state: Optional[Iterable], scores: List,
                progress: int, state_count: int, task: TaskState):
    task.set_status("Getting combinations...")
    task.set_progress_value(0.1)
    states = iterate_states(saved_state)

    task.set_status("Getting scores...")
    res = Result(queue=Queue(), scores=None)
    scores = scores.copy()

    def do_work(st, next_st):
        try:
            score = compute_score(st)
            if score is not None:
                pos = bisect_left(scores, score)
                res.queue.put_nowait(QueuedScore(position=pos, score=score,
                                                 state=st, next_state=next_st))
                scores.insert(pos, score)
        except Exception:  # ignore current state in case of any problem
            pass
        res.scores = scores.copy()
        task.set_partial_result(res)

    state = None
    next_state = next(states)
    try:
        while True:
            if task.is_interruption_requested():
                return res
            task.set_progress_value(int(progress * 100 / max(1, state_count)))
            progress += 1
            state = copy.copy(next_state)
            next_state = copy.copy(next(states))
            do_work(state, next_state)
    except StopIteration:
        do_work(state, None)
    return res


class VizRankDialogAttr(VizRankDialog):
    """
    VizRank dialog for single attributes. The class provides most of the
    needed methods, except for `initialize` which is expected to store a
    list of `Variable` instances to `self.attrs`, and method
    `compute_score(state)` for scoring the combinations.

    The state is an attribute index.

    When the user selects an attribute, the dialog emits signal
    `selectionChanged` with the attribute as parameter.
    """

    attrSelected = Signal(Variable, Variable)
    _AttrRole = next(gui.OrangeUserRole)

    def __init__(self, master):
        super().__init__(master)
        self.attrs = []

    def sizeHint(self):
        """Assuming a single columns in the table, return `QSize(160, 512)` as
        a reasonable default size."""
        return QSize(160, 512)

    def check_preconditions(self):
        """Refuse ranking if there are no features or instances."""
        can_rank = self.master.data is not None and \
            self.master.data.domain.attributes and \
            len(self.master.data) != 0
        self.Information.nothing_to_rank(shown=not can_rank)
        return can_rank

    def on_selection_changed(self, selected, deselected):
        if not selected.isEmpty():
            attr = selected.indexes()[0].data(self._AttrRole)
            self.attrSelected.emit(attr)

    def state_count(self):
        return len(self.attrs)

    def iterate_states(self, initial_state):
        yield from range(initial_state or 0, len(self.attrs))

    def row_for_state(self, score, state):
        attr = self.attrs[state]
        item = QStandardItem(attr.name)
        item.setData(attr, self._AttrRole)
        return [item]


class VizRankDialogAttrPair(VizRankDialog):
    """
    VizRank dialog for pairs of attributes. The class provides most of the
    needed methods, except for `initialize` which is expected to store a
    list of `Variable` instances to `self.attrs`, and method
    `compute_score(state)` for scoring the combinations.

    The state is a pair of indices into `self.attrs`.

    When the user selects a pair, the dialog emits signal `selectionChanged`
    with a tuple of variables as parameter.
    """

    pairSelected = Signal(Variable, Variable)
    _AttrRole = next(gui.OrangeUserRole)

    def __init__(self, master):
        VizRankDialog.__init__(self, master)
        self.resize(320, 512)
        self.attrs = []
        manual_change_signal = getattr(master, "xy_changed_manually", None)
        if manual_change_signal:
            manual_change_signal.connect(self.on_manual_change)

    def sizeHint(self):
        """Assuming two columns in the table, return `QSize(320, 512)` as
        a reasonable default size."""
        return QSize(320, 512)

    def check_preconditions(self):
        """Refuse ranking if there are less than two feature or instances."""
        can_rank = self.master.data is not None and \
            len(self.master.data.domain.attributes) >= 2 and \
            len(self.master.data) >= 2
        self.Information.nothing_to_rank(shown=not can_rank)
        return can_rank

    def on_selection_changed(self, selected, deselected):
        selection = selected.indexes()
        if not selection:
            return
        attrs = selected.indexes()[0].data(self._AttrRole)
        self.selectionChanged.emit(attrs)

    def on_manual_change(self, attr1, attr2):
        model = self.rank_model
        self.rank_table.selectionModel().clear()
        for row in range(model.rowCount()):
            a1, a2 = model.data(model.index(row, 0), self._AttrRole)
            if a1 is attr1 and a2 is attr2:
                self.rank_table.selectRow(row)
                return

    def state_count(self):
        n_attrs = len(self.attrs)
        return n_attrs * (n_attrs - 1) / 2

    def iterate_states(self, initial_state):
        si, sj = initial_state or (0, 0)
        for i in range(si, len(self.attrs)):
            for j in range(sj, i):
                yield i, j
            sj = 0

    def row_for_state(self, score, state):
        attrs = sorted((self.attrs[x] for x in state), key=attrgetter("name"))
        item = QStandardItem(", ".join(a.name for a in attrs))
        item.setData(attrs, self._AttrRole)
        return [item]


class CanvasText(QGraphicsTextItem):
    """QGraphicsTextItem with more convenient constructor

       Args:
           scene (QGraphicsScene): scene into which the text is placed
           text (str): text; see also argument `html_text` (default: `""`)
           x (int): x-coordinate (default: 0)
           y (int): y-coordinate (default: 0)
           alignment (Qt.Alignment): text alignment
               (default: Qt.AlignLeft | Qt.AlignTop)
           bold (bool): if `True`, font is set to bold (default: `False`)
           font (QFont): text font
           z (int): text layer
           html_text (str): text as html; if present (default is `None`),
               it overrides the `text` argument
           tooltip (str): text tooltip
           show (bool): if `False`, the text is hidden (default: `True`)
           vertical (bool): if `True`, the text is rotated by 90 degrees
               (default: `False`)
    """
    def __init__(self, scene, text="", x=0, y=0,
                 alignment=Qt.AlignLeft | Qt.AlignTop, bold=False, font=None,
                 z=0, html_text=None, tooltip=None, show=True, vertical=False,
                 max_width=None):
        QGraphicsTextItem.__init__(self, text, None)

        if font:
            self.setFont(font)
        if bold:
            font = self.font()
            font.setBold(bold)
            self.setFont(font)
        if html_text:
            self.setHtml(html_text)

        self.alignment = alignment
        self.vertical = vertical
        if vertical:
            self.setRotation(-90)

        self.setPos(x, y)
        self.x, self.y = x, y
        self.setZValue(z)
        if tooltip:
            self.setToolTip(tooltip)
        if max_width is not None:
            assert not html_text
            self.elide(max_width)

        if show:
            self.show()
        else:
            self.hide()

        if scene is not None:
            scene.addItem(self)

    def elide(self, max_width):
        if self.boundingRect().width() <= max_width:
            return
        short = self.toPlainText()
        if not self.toolTip():
            self.setToolTip(short)
        while short and self.boundingRect().width() > max_width:
            short = short[:-1]
            self.setPlainText(short + "...")
            # apparently this has to be called to reset position
            self.setPos(self.x, self.y)

    def setPos(self, x, y):
        """setPos with adjustment for alignment"""
        self.x, self.y = x, y
        rect = QGraphicsTextItem.boundingRect(self)
        if self.vertical:
            h, w = rect.height(), rect.width()
            rect.setWidth(h)
            rect.setHeight(-w)
        if int(self.alignment & Qt.AlignRight):
            x -= rect.width()
        elif int(self.alignment & Qt.AlignHCenter):
            x -= rect.width() / 2.
        if int(self.alignment & Qt.AlignBottom):
            y -= rect.height()
        elif int(self.alignment & Qt.AlignVCenter):
            y -= rect.height() / 2.
        QGraphicsTextItem.setPos(self, x, y)


class CanvasRectangle(QGraphicsRectItem):
    """QGraphicsRectItem with more convenient constructor

    Args:
        scene (QGraphicsScene): scene into which the rectangle is placed
        x (int): x-coordinate (default: 0)
        y (int): y-coordinate (default: 0)
        width (int): rectangle's width (default: 0)
        height (int): rectangle's height (default: 0)
        z (int): z-layer
        pen (QPen): pen for the border; if present, it overrides the separate
            arguments for color, width and style
        pen_color (QColor or QPen): the (color of) the pen
            (default: `QColor(128, 128, 128)`)
        pen_width (int): pen width
        pen_style (PenStyle): pen style (default: `Qt.SolidLine`)
        brush_color (QColor): the color for the interior (default: same as pen)
        tooltip (str): tooltip
        show (bool): if `False`, the text is hidden (default: `True`)
        onclick (callable): callback for mouse click event
    """

    def __init__(self, scene, x=0, y=0, width=0, height=0,
                 pen_color=QColor(128, 128, 128), brush_color=None, pen_width=1,
                 z=0, pen_style=Qt.SolidLine, pen=None, tooltip=None, show=True,
                 onclick=None):
        super().__init__(x, y, width, height, None)
        self.onclick = onclick
        if brush_color:
            self.setBrush(QBrush(brush_color))
        if pen:
            self.setPen(pen)
        else:
            self.setPen(QPen(QBrush(pen_color), pen_width, pen_style))
        self.setZValue(z)
        if tooltip:
            self.setToolTip(tooltip)
        if show:
            self.show()
        else:
            self.hide()

        if scene is not None:
            scene.addItem(self)

    def mousePressEvent(self, event):
        if self.onclick:
            self.onclick(self, event)


class ViewWithPress(QGraphicsView):
    """QGraphicsView with a callback for mouse press event. The callback
    is given as keyword argument `handler`.
    """
    def __init__(self, *args, **kwargs):
        self.handler = kwargs.pop("handler")
        super().__init__(*args)

    def mousePressEvent(self, event):
        super().mousePressEvent(event)
        if not event.isAccepted():
            self.handler()

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]

**Title:** VizRankDialog Emits Signals Too Frequently, Causing UI Unresponsiveness

**Description:**

In the `VizRankDialog` component, the method `task.set_partial_result(res)` is being invoked excessively during the visualization ranking process. Specifically, when dealing with simple scores (e.g., correlations widget) and a large number of feature combinations, the `'partial_result_ready'` signal is emitted too frequently. This high frequency of signal emissions leads to the widget becoming unresponsive.

**Example Buggy Code:**

```python
def run_vizrank(compute_score, iterate_states, ...):
    # ... setup code ...
    for state in states:
        do_work(state)
        task.set_partial_result(res)  # Called too often
    return res
```

**Expected Behavior:**

The `task.set_partial_result(res)` method should be called at a controlled rate to limit the frequency of `'partial_result_ready'` signal emissions. This ensures that the UI remains responsive, even when processing numerous feature combinations with simple scoring functions.

**Actual Behavior:**

The `task.set_partial_result(res)` method is called excessively (e.g., 6 times instead of the expected 2), causing the `'partial_result_ready'` signal to be emitted too frequently. This results in the widget becoming unresponsive due to the overwhelming number of signal emissions.

[/ISSUE]
{
    "TestRunner.test_Result": "PASSED",
    "TestRunner.test_run_vizrank": "PASSED",
    "TestRunner.test_run_vizrank_interrupt": "PASSED",
    "TestVizRankDialog.test_on_partial_result": "PASSED"
}
diff --git a/Orange/widgets/visualize/utils/__init__.py b/Orange/widgets/visualize/utils/__init__.py
index d053cf318..248839290 100644
--- a/Orange/widgets/visualize/utils/__init__.py
+++ b/Orange/widgets/visualize/utils/__init__.py
@@ -7,6 +7,7 @@ from operator import attrgetter
 from queue import Queue, Empty
 from types import SimpleNamespace as namespace
 from typing import Optional, Iterable, List, Callable
+from threading import Timer
 
 from AnyQt.QtCore import Qt, QSize, pyqtSignal as Signal, QSortFilterProxyModel
 from AnyQt.QtGui import QStandardItemModel, QStandardItem, QColor, QBrush, QPen
@@ -393,6 +394,7 @@ def run_vizrank(compute_score: Callable, iterate_states: Callable,
     task.set_status("Getting scores...")
     res = Result(queue=Queue(), scores=None)
     scores = scores.copy()
+    can_set_partial_result = True
 
     def do_work(st, next_st):
         try:
@@ -405,7 +407,10 @@ def run_vizrank(compute_score: Callable, iterate_states: Callable,
         except Exception:  # ignore current state in case of any problem
             pass
         res.scores = scores.copy()
-        task.set_partial_result(res)
+
+    def reset_flag():
+        nonlocal can_set_partial_result
+        can_set_partial_result = True
 
     state = None
     next_state = next(states)
@@ -418,8 +423,18 @@ def run_vizrank(compute_score: Callable, iterate_states: Callable,
             state = copy.copy(next_state)
             next_state = copy.copy(next(states))
             do_work(state, next_state)
+            # for simple scores (e.g. correlations widget) and many feature
+            # combinations, the 'partial_result_ready' signal (emitted by
+            # invoking 'task.set_partial_result') was emitted too frequently
+            # for a longer period of time and therefore causing the widget
+            # being unresponsive
+            if can_set_partial_result:
+                task.set_partial_result(res)
+                can_set_partial_result = False
+                Timer(0.01, reset_flag).start()
     except StopIteration:
         do_work(state, None)
+        task.set_partial_result(res)
     return res
 
 
 

{"Orange/widgets/visualize/utils/__init__.py": "\"\"\"\nUtility classes for visualization widgets\n\"\"\"\nimport copy\nfrom bisect import bisect_left\nfrom operator import attrgetter\nfrom queue import Queue, Empty\nfrom types import SimpleNamespace as namespace\nfrom typing import Optional, Iterable, List, Callable\n\nfrom AnyQt.QtCore import Qt, QSize, pyqtSignal as Signal, QSortFilterProxyModel\nfrom AnyQt.QtGui import QStandardItemModel, QStandardItem, QColor, QBrush, QPen\nfrom AnyQt.QtWidgets import (\n    QTableView, QGraphicsTextItem, QGraphicsRectItem, QGraphicsView, QDialog,\n    QVBoxLayout, QLineEdit\n)\nfrom Orange.data import Variable\nfrom Orange.widgets import gui\nfrom Orange.widgets.gui import HorizontalGridDelegate, TableBarItem\nfrom Orange.widgets.utils.concurrent import ConcurrentMixin, TaskState\nfrom Orange.widgets.utils.messages import WidgetMessagesMixin\nfrom Orange.widgets.utils.progressbar import ProgressBarMixin\nfrom Orange.widgets.widget import Msg\n\n\nclass Result(namespace):\n    queue = None  # type: Queue[QueuedScore, ...]\n    scores = None  # type: Optional[List[float, ...]]\n\n\nclass QueuedScore(namespace):\n    position = None  # type: int\n    score = None  # type: float\n    state = None  # type: Iterable\n    next_state = None  # type: Iterable\n\n\nclass VizRankDialog(QDialog, ProgressBarMixin, WidgetMessagesMixin,\n                    ConcurrentMixin):\n    \"\"\"\n    Base class for VizRank dialogs, providing a GUI with a table and a button,\n    and the skeleton for managing the evaluation of visualizations.\n\n    Derived classes must provide methods\n\n    - `iterate_states` for generating combinations (e.g. pairs of attritutes),\n    - `compute_score(state)` for computing the score of a combination,\n    - `row_for_state(state)` that returns a list of items inserted into the\n       table for the given state.\n\n    and, optionally,\n\n    - `state_count` that returns the number of combinations (used for progress\n       bar)\n    - `on_selection_changed` that handles event triggered when the user selects\n      a table row. The method should emit signal\n      `VizRankDialog.selectionChanged(object)`.\n    - `bar_length` returns the length of the bar corresponding to the score.\n\n    The class provides a table and a button. A widget constructs a single\n    instance of this dialog in its `__init__`, like (in Sieve) by using a\n    convenience method :obj:`add_vizrank`::\n\n        self.vizrank, self.vizrank_button = SieveRank.add_vizrank(\n            box, self, \"Score Combinations\", self.set_attr)\n\n    When the widget receives new data, it must call the VizRankDialog's\n    method :obj:`VizRankDialog.initialize()` to clear the GUI and reset the\n    state.\n\n    Clicking the Start button calls method `run` (and renames the button to\n    Pause). Run sets up a progress bar by getting the number of combinations\n    from :obj:`VizRankDialog.state_count()`. It restores the paused state\n    (if any) and calls generator :obj:`VizRankDialog.iterate_states()`. For\n    each generated state, it calls :obj:`VizRankDialog.score(state)`, which\n    must return the score (lower is better) for this state. If the returned\n    state is not `None`, the data returned by `row_for_state` is inserted at\n    the appropriate place in the table.\n\n    Args:\n        master (Orange.widget.OWWidget): widget to which the dialog belongs\n\n    Attributes:\n        master (Orange.widget.OWWidget): widget to which the dialog belongs\n        captionTitle (str): the caption for the dialog. This can be a class\n          attribute. `captionTitle` is used by the `ProgressBarMixin`.\n    \"\"\"\n\n    captionTitle = \"\"\n\n    NEGATIVE_COLOR = QColor(70, 190, 250)\n    POSITIVE_COLOR = QColor(170, 242, 43)\n\n    processingStateChanged = Signal(int)\n    progressBarValueChanged = Signal(float)\n    messageActivated = Signal(Msg)\n    messageDeactivated = Signal(Msg)\n    selectionChanged = Signal(object)\n\n    class Information(WidgetMessagesMixin.Information):\n        nothing_to_rank = Msg(\"There is nothing to rank.\")\n\n    def __init__(self, master):\n        \"\"\"Initialize the attributes and set up the interface\"\"\"\n        QDialog.__init__(self, master, windowTitle=self.captionTitle)\n        WidgetMessagesMixin.__init__(self)\n        ConcurrentMixin.__init__(self)\n        self.setLayout(QVBoxLayout())\n\n        self.insert_message_bar()\n        self.layout().insertWidget(0, self.message_bar)\n        self.master = master\n\n        self.keep_running = False\n        self.scheduled_call = None\n        self.saved_state = None\n        self.saved_progress = 0\n        self.scores = []\n        self.add_to_model = Queue()\n\n        self.filter = QLineEdit()\n        self.filter.setPlaceholderText(\"Filter ...\")\n        self.filter.textChanged.connect(self.filter_changed)\n        self.layout().addWidget(self.filter)\n        # Remove focus from line edit\n        self.setFocus(Qt.ActiveWindowFocusReason)\n\n        self.rank_model = QStandardItemModel(self)\n        self.model_proxy = QSortFilterProxyModel(\n            self, filterCaseSensitivity=False)\n        self.model_proxy.setSourceModel(self.rank_model)\n        self.rank_table = view = QTableView(\n            selectionBehavior=QTableView.SelectRows,\n            selectionMode=QTableView.SingleSelection,\n            showGrid=False,\n            editTriggers=gui.TableView.NoEditTriggers)\n        if self._has_bars:\n            view.setItemDelegate(TableBarItem())\n        else:\n            view.setItemDelegate(HorizontalGridDelegate())\n        view.setModel(self.model_proxy)\n        view.selectionModel().selectionChanged.connect(\n            self.on_selection_changed)\n        view.horizontalHeader().setStretchLastSection(True)\n        view.horizontalHeader().hide()\n        self.layout().addWidget(view)\n\n        self.button = gui.button(\n            self, self, \"Start\", callback=self.toggle, default=True)\n\n    @property\n    def _has_bars(self):\n        return type(self).bar_length is not VizRankDialog.bar_length\n\n    @classmethod\n    def add_vizrank(cls, widget, master, button_label, set_attr_callback):\n        \"\"\"\n        Equip the widget with VizRank button and dialog, and monkey patch the\n        widget's `closeEvent` and `hideEvent` to close/hide the vizrank, too.\n\n        Args:\n            widget (QWidget): the widget into whose layout to insert the button\n            master (Orange.widgets.widget.OWWidget): the master widget\n            button_label: the label for the button\n            set_attr_callback: the callback for setting the projection chosen\n                in the vizrank\n\n        Returns:\n            tuple with Vizrank dialog instance and push button\n        \"\"\"\n        # Monkey patching could be avoided by mixing-in the class (not\n        # necessarily a good idea since we can make a mess of multiple\n        # defined/derived closeEvent and hideEvent methods). Furthermore,\n        # per-class patching would be better than per-instance, but we don't\n        # want to mess with meta-classes either.\n\n        vizrank = cls(master)\n        button = gui.button(\n            widget, master, button_label, callback=vizrank.reshow,\n            enabled=False)\n        vizrank.selectionChanged.connect(lambda args: set_attr_callback(*args))\n\n        master_close_event = master.closeEvent\n        master_hide_event = master.hideEvent\n        master_delete_event = master.onDeleteWidget\n\n        def closeEvent(event):\n            vizrank.close()\n            master_close_event(event)\n\n        def hideEvent(event):\n            vizrank.hide()\n            master_hide_event(event)\n\n        def deleteEvent():\n            vizrank.keep_running = False\n            vizrank.shutdown()\n            master_delete_event()\n\n        master.closeEvent = closeEvent\n        master.hideEvent = hideEvent\n        master.onDeleteWidget = deleteEvent\n        return vizrank, button\n\n    def reshow(self):\n        \"\"\"Put the widget on top of all windows\n        \"\"\"\n        self.show()\n        self.raise_()\n        self.activateWindow()\n\n    def initialize(self):\n        \"\"\"\n        Clear and initialize the dialog.\n\n        This method must be called by the widget when the data is reset,\n        e.g. from `set_data` handler.\n        \"\"\"\n        if self.task is not None:\n            self.keep_running = False\n            self.cancel()\n        self.keep_running = False\n        self.scheduled_call = None\n        self.saved_state = None\n        self.saved_progress = 0\n        self.progressBarFinished()\n        self.scores = []\n        self._update_model()  # empty queue\n        self.rank_model.clear()\n        self.button.setText(\"Start\")\n        self.button.setEnabled(self.check_preconditions())\n\n    def filter_changed(self, text):\n        self.model_proxy.setFilterFixedString(text)\n\n    def stop_and_reset(self, reset_method=None):\n        if self.keep_running:\n            self.scheduled_call = reset_method or self.initialize\n            self.keep_running = False\n        else:\n            self.initialize()\n\n    def check_preconditions(self):\n        \"\"\"Check whether there is sufficient data for ranking.\"\"\"\n        return True\n\n    def on_selection_changed(self, selected, deselected):\n        \"\"\"\n        Set the new visualization in the widget when the user select a\n        row in the table.\n\n        If derived class does not reimplement this, the table gives the\n        information but the user can't click it to select the visualization.\n\n        Args:\n            selected: the index of the selected item\n            deselected: the index of the previously selected item\n        \"\"\"\n        pass\n\n    def iterate_states(self, initial_state):\n        \"\"\"\n        Generate all possible states (e.g. attribute combinations) for the\n        given data. The content of the generated states is specific to the\n        visualization.\n\n        This method must be defined in the derived classes.\n\n        Args:\n            initial_state: initial state; None if this is the first call\n        \"\"\"\n        raise NotImplementedError\n\n    def state_count(self):\n        \"\"\"\n        Return the number of states for the progress bar.\n\n        Derived classes should implement this to ensure the proper behaviour of\n        the progress bar\"\"\"\n        return 0\n\n    def compute_score(self, state):\n        \"\"\"\n        Abstract method for computing the score for the given state. Smaller\n        scores are better.\n\n        Args:\n            state: the state, e.g. the combination of attributes as generated\n                by :obj:`state_count`.\n        \"\"\"\n        raise NotImplementedError\n\n    def bar_length(self, score):\n        \"\"\"Compute the bar length (between 0 and 1) corresponding to the score.\n        Return `None` if the score cannot be normalized.\n        \"\"\"\n        return None\n\n    def row_for_state(self, score, state):\n        \"\"\"\n        Abstract method that return the items that are inserted into the table.\n\n        Args:\n            score: score, computed by :obj:`compute_score`\n            state: the state, e.g. combination of attributes\n            \"\"\"\n        raise NotImplementedError\n\n    def _select_first_if_none(self):\n        if not self.rank_table.selectedIndexes():\n            self.rank_table.selectRow(0)\n\n    def on_partial_result(self, result: Result):\n        try:\n            while True:\n                queued = result.queue.get_nowait()\n                self.saved_state = queued.next_state\n                self.add_to_model.put_nowait(queued)\n        except Empty:\n            pass\n        self.scores = result.scores\n        self.saved_progress = len(self.scores)\n        self._update()\n\n    def on_done(self, result: Result):\n        self.button.setText(\"Finished\")\n        self.button.setEnabled(False)\n        self.keep_running = False\n        self.saved_state = None\n        self._stopped()\n\n    def _stopped(self):\n        self.progressBarFinished()\n        self._update_model()\n        self.stopped()\n        if self.scheduled_call:\n            self.scheduled_call()\n        self._select_first_if_none()\n\n    def _update(self):\n        self._update_model()\n        self._update_progress()\n\n    def _update_progress(self):\n        self.progressBarSet(int(self.saved_progress * 100 / max(1, self.state_count())))\n\n    def _update_model(self):\n        try:\n            while True:\n                queued = self.add_to_model.get_nowait()\n                row_items = self.row_for_state(queued.score, queued.state)\n                bar_length = self.bar_length(queued.score)\n                if bar_length is not None:\n                    row_items[0].setData(bar_length,\n                                         gui.TableBarItem.BarRole)\n                self.rank_model.insertRow(queued.position, row_items)\n        except Empty:\n            pass\n\n    def toggle(self):\n        \"\"\"Start or pause the computation.\"\"\"\n        self.keep_running = not self.keep_running\n        if self.keep_running:\n            self.button.setText(\"Pause\")\n            self.button.repaint()\n            self.progressBarInit()\n            self.before_running()\n            self.start(run_vizrank, self.compute_score,\n                       self.iterate_states, self.saved_state, self.scores,\n                       self.saved_progress, self.state_count())\n        else:\n            self.button.setText(\"Continue\")\n            self.button.repaint()\n            self.cancel()\n            self._stopped()\n\n    def before_running(self):\n        \"\"\"Code that is run before running vizrank in its own thread\"\"\"\n        pass\n\n    def stopped(self):\n        \"\"\"Code that is run after stopping the vizrank thread\"\"\"\n        pass\n\n\ndef run_vizrank(compute_score: Callable, iterate_states: Callable,\n                saved_state: Optional[Iterable], scores: List,\n                progress: int, state_count: int, task: TaskState):\n    task.set_status(\"Getting combinations...\")\n    task.set_progress_value(0.1)\n    states = iterate_states(saved_state)\n\n    task.set_status(\"Getting scores...\")\n    res = Result(queue=Queue(), scores=None)\n    scores = scores.copy()\n\n    def do_work(st, next_st):\n        try:\n            score = compute_score(st)\n            if score is not None:\n                pos = bisect_left(scores, score)\n                res.queue.put_nowait(QueuedScore(position=pos, score=score,\n                                                 state=st, next_state=next_st))\n                scores.insert(pos, score)\n        except Exception:  # ignore current state in case of any problem\n            pass\n        res.scores = scores.copy()\n        task.set_partial_result(res)\n\n    state = None\n    next_state = next(states)\n    try:\n        while True:\n            if task.is_interruption_requested():\n                return res\n            task.set_progress_value(int(progress * 100 / max(1, state_count)))\n            progress += 1\n            state = copy.copy(next_state)\n            next_state = copy.copy(next(states))\n            do_work(state, next_state)\n    except StopIteration:\n        do_work(state, None)\n    return res\n\n\nclass VizRankDialogAttr(VizRankDialog):\n    \"\"\"\n    VizRank dialog for single attributes. The class provides most of the\n    needed methods, except for `initialize` which is expected to store a\n    list of `Variable` instances to `self.attrs`, and method\n    `compute_score(state)` for scoring the combinations.\n\n    The state is an attribute index.\n\n    When the user selects an attribute, the dialog emits signal\n    `selectionChanged` with the attribute as parameter.\n    \"\"\"\n\n    attrSelected = Signal(Variable, Variable)\n    _AttrRole = next(gui.OrangeUserRole)\n\n    def __init__(self, master):\n        super().__init__(master)\n        self.attrs = []\n\n    def sizeHint(self):\n        \"\"\"Assuming a single columns in the table, return `QSize(160, 512)` as\n        a reasonable default size.\"\"\"\n        return QSize(160, 512)\n\n    def check_preconditions(self):\n        \"\"\"Refuse ranking if there are no features or instances.\"\"\"\n        can_rank = self.master.data is not None and \\\n            self.master.data.domain.attributes and \\\n            len(self.master.data) != 0\n        self.Information.nothing_to_rank(shown=not can_rank)\n        return can_rank\n\n    def on_selection_changed(self, selected, deselected):\n        if not selected.isEmpty():\n            attr = selected.indexes()[0].data(self._AttrRole)\n            self.attrSelected.emit(attr)\n\n    def state_count(self):\n        return len(self.attrs)\n\n    def iterate_states(self, initial_state):\n        yield from range(initial_state or 0, len(self.attrs))\n\n    def row_for_state(self, score, state):\n        attr = self.attrs[state]\n        item = QStandardItem(attr.name)\n        item.setData(attr, self._AttrRole)\n        return [item]\n\n\nclass VizRankDialogAttrPair(VizRankDialog):\n    \"\"\"\n    VizRank dialog for pairs of attributes. The class provides most of the\n    needed methods, except for `initialize` which is expected to store a\n    list of `Variable` instances to `self.attrs`, and method\n    `compute_score(state)` for scoring the combinations.\n\n    The state is a pair of indices into `self.attrs`.\n\n    When the user selects a pair, the dialog emits signal `selectionChanged`\n    with a tuple of variables as parameter.\n    \"\"\"\n\n    pairSelected = Signal(Variable, Variable)\n    _AttrRole = next(gui.OrangeUserRole)\n\n    def __init__(self, master):\n        VizRankDialog.__init__(self, master)\n        self.resize(320, 512)\n        self.attrs = []\n        manual_change_signal = getattr(master, \"xy_changed_manually\", None)\n        if manual_change_signal:\n            manual_change_signal.connect(self.on_manual_change)\n\n    def sizeHint(self):\n        \"\"\"Assuming two columns in the table, return `QSize(320, 512)` as\n        a reasonable default size.\"\"\"\n        return QSize(320, 512)\n\n    def check_preconditions(self):\n        \"\"\"Refuse ranking if there are less than two feature or instances.\"\"\"\n        can_rank = self.master.data is not None and \\\n            len(self.master.data.domain.attributes) >= 2 and \\\n            len(self.master.data) >= 2\n        self.Information.nothing_to_rank(shown=not can_rank)\n        return can_rank\n\n    def on_selection_changed(self, selected, deselected):\n        selection = selected.indexes()\n        if not selection:\n            return\n        attrs = selected.indexes()[0].data(self._AttrRole)\n        self.selectionChanged.emit(attrs)\n\n    def on_manual_change(self, attr1, attr2):\n        model = self.rank_model\n        self.rank_table.selectionModel().clear()\n        for row in range(model.rowCount()):\n            a1, a2 = model.data(model.index(row, 0), self._AttrRole)\n            if a1 is attr1 and a2 is attr2:\n                self.rank_table.selectRow(row)\n                return\n\n    def state_count(self):\n        n_attrs = len(self.attrs)\n        return n_attrs * (n_attrs - 1) / 2\n\n    def iterate_states(self, initial_state):\n        si, sj = initial_state or (0, 0)\n        for i in range(si, len(self.attrs)):\n            for j in range(sj, i):\n                yield i, j\n            sj = 0\n\n    def row_for_state(self, score, state):\n        attrs = sorted((self.attrs[x] for x in state), key=attrgetter(\"name\"))\n        item = QStandardItem(\", \".join(a.name for a in attrs))\n        item.setData(attrs, self._AttrRole)\n        return [item]\n\n\nclass CanvasText(QGraphicsTextItem):\n    \"\"\"QGraphicsTextItem with more convenient constructor\n\n       Args:\n           scene (QGraphicsScene): scene into which the text is placed\n           text (str): text; see also argument `html_text` (default: `\"\"`)\n           x (int): x-coordinate (default: 0)\n           y (int): y-coordinate (default: 0)\n           alignment (Qt.Alignment): text alignment\n               (default: Qt.AlignLeft | Qt.AlignTop)\n           bold (bool): if `True`, font is set to bold (default: `False`)\n           font (QFont): text font\n           z (int): text layer\n           html_text (str): text as html; if present (default is `None`),\n               it overrides the `text` argument\n           tooltip (str): text tooltip\n           show (bool): if `False`, the text is hidden (default: `True`)\n           vertical (bool): if `True`, the text is rotated by 90 degrees\n               (default: `False`)\n    \"\"\"\n    def __init__(self, scene, text=\"\", x=0, y=0,\n                 alignment=Qt.AlignLeft | Qt.AlignTop, bold=False, font=None,\n                 z=0, html_text=None, tooltip=None, show=True, vertical=False,\n                 max_width=None):\n        QGraphicsTextItem.__init__(self, text, None)\n\n        if font:\n            self.setFont(font)\n        if bold:\n            font = self.font()\n            font.setBold(bold)\n            self.setFont(font)\n        if html_text:\n            self.setHtml(html_text)\n\n        self.alignment = alignment\n        self.vertical = vertical\n        if vertical:\n            self.setRotation(-90)\n\n        self.setPos(x, y)\n        self.x, self.y = x, y\n        self.setZValue(z)\n        if tooltip:\n            self.setToolTip(tooltip)\n        if max_width is not None:\n            assert not html_text\n            self.elide(max_width)\n\n        if show:\n            self.show()\n        else:\n            self.hide()\n\n        if scene is not None:\n            scene.addItem(self)\n\n    def elide(self, max_width):\n        if self.boundingRect().width() <= max_width:\n            return\n        short = self.toPlainText()\n        if not self.toolTip():\n            self.setToolTip(short)\n        while short and self.boundingRect().width() > max_width:\n            short = short[:-1]\n            self.setPlainText(short + \"...\")\n            # apparently this has to be called to reset position\n            self.setPos(self.x, self.y)\n\n    def setPos(self, x, y):\n        \"\"\"setPos with adjustment for alignment\"\"\"\n        self.x, self.y = x, y\n        rect = QGraphicsTextItem.boundingRect(self)\n        if self.vertical:\n            h, w = rect.height(), rect.width()\n            rect.setWidth(h)\n            rect.setHeight(-w)\n        if int(self.alignment & Qt.AlignRight):\n            x -= rect.width()\n        elif int(self.alignment & Qt.AlignHCenter):\n            x -= rect.width() / 2.\n        if int(self.alignment & Qt.AlignBottom):\n            y -= rect.height()\n        elif int(self.alignment & Qt.AlignVCenter):\n            y -= rect.height() / 2.\n        QGraphicsTextItem.setPos(self, x, y)\n\n\nclass CanvasRectangle(QGraphicsRectItem):\n    \"\"\"QGraphicsRectItem with more convenient constructor\n\n    Args:\n        scene (QGraphicsScene): scene into which the rectangle is placed\n        x (int): x-coordinate (default: 0)\n        y (int): y-coordinate (default: 0)\n        width (int): rectangle's width (default: 0)\n        height (int): rectangle's height (default: 0)\n        z (int): z-layer\n        pen (QPen): pen for the border; if present, it overrides the separate\n            arguments for color, width and style\n        pen_color (QColor or QPen): the (color of) the pen\n            (default: `QColor(128, 128, 128)`)\n        pen_width (int): pen width\n        pen_style (PenStyle): pen style (default: `Qt.SolidLine`)\n        brush_color (QColor): the color for the interior (default: same as pen)\n        tooltip (str): tooltip\n        show (bool): if `False`, the text is hidden (default: `True`)\n        onclick (callable): callback for mouse click event\n    \"\"\"\n\n    def __init__(self, scene, x=0, y=0, width=0, height=0,\n                 pen_color=QColor(128, 128, 128), brush_color=None, pen_width=1,\n                 z=0, pen_style=Qt.SolidLine, pen=None, tooltip=None, show=True,\n                 onclick=None):\n        super().__init__(x, y, width, height, None)\n        self.onclick = onclick\n        if brush_color:\n            self.setBrush(QBrush(brush_color))\n        if pen:\n            self.setPen(pen)\n        else:\n            self.setPen(QPen(QBrush(pen_color), pen_width, pen_style))\n        self.setZValue(z)\n        if tooltip:\n            self.setToolTip(tooltip)\n        if show:\n            self.show()\n        else:\n            self.hide()\n\n        if scene is not None:\n            scene.addItem(self)\n\n    def mousePressEvent(self, event):\n        if self.onclick:\n            self.onclick(self, event)\n\n\nclass ViewWithPress(QGraphicsView):\n    \"\"\"QGraphicsView with a callback for mouse press event. The callback\n    is given as keyword argument `handler`.\n    \"\"\"\n    def __init__(self, *args, **kwargs):\n        self.handler = kwargs.pop(\"handler\")\n        super().__init__(*args)\n\n    def mousePressEvent(self, event):\n        super().mousePressEvent(event)\n        if not event.isAccepted():\n            self.handler()\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]

**Title:** VizRankDialog Emits Signals Too Frequently, Causing UI Unresponsiveness

**Description:**

In the `VizRankDialog` component, the method `task.set_partial_result(res)` is being invoked excessively during the visualization ranking process. Specifically, when dealing with simple scores (e.g., correlations widget) and a large number of feature combinations, the `'partial_result_ready'` signal is emitted too frequently. This high frequency of signal emissions leads to the widget becoming unresponsive.

**Example Buggy Code:**

```python
def run_vizrank(compute_score, iterate_states, ...):
    # ... setup code ...
    for state in states:
        do_work(state)
        task.set_partial_result(res)  # Called too often
    return res
```

**Expected Behavior:**

The `task.set_partial_result(res)` method should be called at a controlled rate to limit the frequency of `'partial_result_ready'` signal emissions. This ensures that the UI remains responsive, even when processing numerous feature combinations with simple scoring functions.

**Actual Behavior:**

The `task.set_partial_result(res)` method is called excessively (e.g., 6 times instead of the expected 2), causing the `'partial_result_ready'` signal to be emitted too frequently. This results in the widget becoming unresponsive due to the overwhelming number of signal emissions.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### Orange/widgets/visualize/utils/__init__.py
"""
Utility classes for visualization widgets
"""
import copy
from bisect import bisect_left
from operator import attrgetter
from queue import Queue, Empty
from types import SimpleNamespace as namespace
from typing import Optional, Iterable, List, Callable

from AnyQt.QtCore import Qt, QSize, pyqtSignal as Signal, QSortFilterProxyModel
from AnyQt.QtGui import QStandardItemModel, QStandardItem, QColor, QBrush, QPen
from AnyQt.QtWidgets import (
    QTableView, QGraphicsTextItem, QGraphicsRectItem, QGraphicsView, QDialog,
    QVBoxLayout, QLineEdit
)
from Orange.data import Variable
from Orange.widgets import gui
from Orange.widgets.gui import HorizontalGridDelegate, TableBarItem
from Orange.widgets.utils.concurrent import ConcurrentMixin, TaskState
from Orange.widgets.utils.messages import WidgetMessagesMixin
from Orange.widgets.utils.progressbar import ProgressBarMixin
from Orange.widgets.widget import Msg


class Result(namespace):
    queue = None  # type: Queue[QueuedScore, ...]
    scores = None  # type: Optional[List[float, ...]]


class QueuedScore(namespace):
    position = None  # type: int
    score = None  # type: float
    state = None  # type: Iterable
    next_state = None  # type: Iterable


class VizRankDialog(QDialog, ProgressBarMixin, WidgetMessagesMixin,
                    ConcurrentMixin):
    """
    Base class for VizRank dialogs, providing a GUI with a table and a button,
    and the skeleton for managing the evaluation of visualizations.

    Derived classes must provide methods

    - `iterate_states` for generating combinations (e.g. pairs of attritutes),
    - `compute_score(state)` for computing the score of a combination,
    - `row_for_state(state)` that returns a list of items inserted into the
       table for the given state.

    and, optionally,

    - `state_count` that returns the number of combinations (used for progress
       bar)
    - `on_selection_changed` that handles event triggered when the user selects
      a table row. The method should emit signal
      `VizRankDialog.selectionChanged(object)`.
    - `bar_length` returns the length of the bar corresponding to the score.

    The class provides a table and a button. A widget constructs a single
    instance of this dialog in its `__init__`, like (in Sieve) by using a
    convenience method :obj:`add_vizrank`::

        self.vizrank, self.vizrank_button = SieveRank.add_vizrank(
            box, self, "Score Combinations", self.set_attr)

    When the widget receives new data, it must call the VizRankDialog's
    method :obj:`VizRankDialog.initialize()` to clear the GUI and reset the
    state.

    Clicking the Start button calls method `run` (and renames the button to
    Pause). Run sets up a progress bar by getting the number of combinations
    from :obj:`VizRankDialog.state_count()`. It restores the paused state
    (if any) and calls generator :obj:`VizRankDialog.iterate_states()`. For
    each generated state, it calls :obj:`VizRankDialog.score(state)`, which
    must return the score (lower is better) for this state. If the returned
    state is not `None`, the data returned by `row_for_state` is inserted at
    the appropriate place in the table.

    Args:
        master (Orange.widget.OWWidget): widget to which the dialog belongs

    Attributes:
        master (Orange.widget.OWWidget): widget to which the dialog belongs
        captionTitle (str): the caption for the dialog. This can be a class
          attribute. `captionTitle` is used by the `ProgressBarMixin`.
    """

    captionTitle = ""

    NEGATIVE_COLOR = QColor(70, 190, 250)
    POSITIVE_COLOR = QColor(170, 242, 43)

    processingStateChanged = Signal(int)
    progressBarValueChanged = Signal(float)
    messageActivated = Signal(Msg)
    messageDeactivated = Signal(Msg)
    selectionChanged = Signal(object)

    class Information(WidgetMessagesMixin.Information):
        nothing_to_rank = Msg("There is nothing to rank.")

    def __init__(self, master):
        """Initialize the attributes and set up the interface"""
        QDialog.__init__(self, master, windowTitle=self.captionTitle)
        WidgetMessagesMixin.__init__(self)
        ConcurrentMixin.__init__(self)
        self.setLayout(QVBoxLayout())

        self.insert_message_bar()
        self.layout().insertWidget(0, self.message_bar)
        self.master = master

        self.keep_running = False
        self.scheduled_call = None
        self.saved_state = None
        self.saved_progress = 0
        self.scores = []
        self.add_to_model = Queue()

        self.filter = QLineEdit()
        self.filter.setPlaceholderText("Filter ...")
        self.filter.textChanged.connect(self.filter_changed)
        self.layout().addWidget(self.filter)
        # Remove focus from line edit
        self.setFocus(Qt.ActiveWindowFocusReason)

        self.rank_model = QStandardItemModel(self)
        self.model_proxy = QSortFilterProxyModel(
            self, filterCaseSensitivity=False)
        self.model_proxy.setSourceModel(self.rank_model)
        self.rank_table = view = QTableView(
            selectionBehavior=QTableView.SelectRows,
            selectionMode=QTableView.SingleSelection,
            showGrid=False,
            editTriggers=gui.TableView.NoEditTriggers)
        if self._has_bars:
            view.setItemDelegate(TableBarItem())
        else:
            view.setItemDelegate(HorizontalGridDelegate())
        view.setModel(self.model_proxy)
        view.selectionModel().selectionChanged.connect(
            self.on_selection_changed)
        view.horizontalHeader().setStretchLastSection(True)
        view.horizontalHeader().hide()
        self.layout().addWidget(view)

        self.button = gui.button(
            self, self, "Start", callback=self.toggle, default=True)

    @property
    def _has_bars(self):
        return type(self).bar_length is not VizRankDialog.bar_length

    @classmethod
    def add_vizrank(cls, widget, master, button_label, set_attr_callback):
        """
        Equip the widget with VizRank button and dialog, and monkey patch the
        widget's `closeEvent` and `hideEvent` to close/hide the vizrank, too.

        Args:
            widget (QWidget): the widget into whose layout to insert the button
            master (Orange.widgets.widget.OWWidget): the master widget
            button_label: the label for the button
            set_attr_callback: the callback for setting the projection chosen
                in the vizrank

        Returns:
            tuple with Vizrank dialog instance and push button
        """
        # Monkey patching could be avoided by mixing-in the class (not
        # necessarily a good idea since we can make a mess of multiple
        # defined/derived closeEvent and hideEvent methods). Furthermore,
        # per-class patching would be better than per-instance, but we don't
        # want to mess with meta-classes either.

        vizrank = cls(master)
        button = gui.button(
            widget, master, button_label, callback=vizrank.reshow,
            enabled=False)
        vizrank.selectionChanged.connect(lambda args: set_attr_callback(*args))

        master_close_event = master.closeEvent
        master_hide_event = master.hideEvent
        master_delete_event = master.onDeleteWidget

        def closeEvent(event):
            vizrank.close()
            master_close_event(event)

        def hideEvent(event):
            vizrank.hide()
            master_hide_event(event)

        def deleteEvent():
            vizrank.keep_running = False
            vizrank.shutdown()
            master_delete_event()

        master.closeEvent = closeEvent
        master.hideEvent = hideEvent
        master.onDeleteWidget = deleteEvent
        return vizrank, button

    def reshow(self):
        """Put the widget on top of all windows
        """
        self.show()
        self.raise_()
        self.activateWindow()

    def initialize(self):
        """
        Clear and initialize the dialog.

        This method must be called by the widget when the data is reset,
        e.g. from `set_data` handler.
        """
        if self.task is not None:
            self.keep_running = False
            self.cancel()
        self.keep_running = False
        self.scheduled_call = None
        self.saved_state = None
        self.saved_progress = 0
        self.progressBarFinished()
        self.scores = []
        self._update_model()  # empty queue
        self.rank_model.clear()
        self.button.setText("Start")
        self.button.setEnabled(self.check_preconditions())

    def filter_changed(self, text):
        self.model_proxy.setFilterFixedString(text)

    def stop_and_reset(self, reset_method=None):
        if self.keep_running:
            self.scheduled_call = reset_method or self.initialize
            self.keep_running = False
        else:
            self.initialize()

    def check_preconditions(self):
        """Check whether there is sufficient data for ranking."""
        return True

    def on_selection_changed(self, selected, deselected):
        """
        Set the new visualization in the widget when the user select a
        row in the table.

        If derived class does not reimplement this, the table gives the
        information but the user can't click it to select the visualization.

        Args:
            selected: the index of the selected item
            deselected: the index of the previously selected item
        """
        pass

    def iterate_states(self, initial_state):
        """
        Generate all possible states (e.g. attribute combinations) for the
        given data. The content of the generated states is specific to the
        visualization.

        This method must be defined in the derived classes.

        Args:
            initial_state: initial state; None if this is the first call
        """
        raise NotImplementedError

    def state_count(self):
        """
        Return the number of states for the progress bar.

        Derived classes should implement this to ensure the proper behaviour of
        the progress bar"""
        return 0

    def compute_score(self, state):
        """
        Abstract method for computing the score for the given state. Smaller
        scores are better.

        Args:
            state: the state, e.g. the combination of attributes as generated
                by :obj:`state_count`.
        """
        raise NotImplementedError

    def bar_length(self, score):
        """Compute the bar length (between 0 and 1) corresponding to the score.
        Return `None` if the score cannot be normalized.
        """
        return None

    def row_for_state(self, score, state):
        """
        Abstract method that return the items that are inserted into the table.

        Args:
            score: score, computed by :obj:`compute_score`
            state: the state, e.g. combination of attributes
            """
        raise NotImplementedError

    def _select_first_if_none(self):
        if not self.rank_table.selectedIndexes():
            self.rank_table.selectRow(0)

    def on_partial_result(self, result: Result):
        try:
            while True:
                queued = result.queue.get_nowait()
                self.saved_state = queued.next_state
                self.add_to_model.put_nowait(queued)
        except Empty:
            pass
        self.scores = result.scores
        self.saved_progress = len(self.scores)
        self._update()

    def on_done(self, result: Result):
        self.button.setText("Finished")
        self.button.setEnabled(False)
        self.keep_running = False
        self.saved_state = None
        self._stopped()

    def _stopped(self):
        self.progressBarFinished()
        self._update_model()
        self.stopped()
        if self.scheduled_call:
            self.scheduled_call()
        self._select_first_if_none()

    def _update(self):
        self._update_model()
        self._update_progress()

    def _update_progress(self):
        self.progressBarSet(int(self.saved_progress * 100 / max(1, self.state_count())))

    def _update_model(self):
        try:
            while True:
                queued = self.add_to_model.get_nowait()
                row_items = self.row_for_state(queued.score, queued.state)
                bar_length = self.bar_length(queued.score)
                if bar_length is not None:
                    row_items[0].setData(bar_length,
                                         gui.TableBarItem.BarRole)
                self.rank_model.insertRow(queued.position, row_items)
        except Empty:
            pass

    def toggle(self):
        """Start or pause the computation."""
        self.keep_running = not self.keep_running
        if self.keep_running:
            self.button.setText("Pause")
            self.button.repaint()
            self.progressBarInit()
            self.before_running()
            self.start(run_vizrank, self.compute_score,
                       self.iterate_states, self.saved_state, self.scores,
                       self.saved_progress, self.state_count())
        else:
            self.button.setText("Continue")
            self.button.repaint()
            self.cancel()
            self._stopped()

    def before_running(self):
        """Code that is run before running vizrank in its own thread"""
        pass

    def stopped(self):
        """Code that is run after stopping the vizrank thread"""
        pass


def run_vizrank(compute_score: Callable, iterate_states: Callable,
                saved_state: Optional[Iterable], scores: List,
                progress: int, state_count: int, task: TaskState):
    task.set_status("Getting combinations...")
    task.set_progress_value(0.1)
    states = iterate_states(saved_state)

    task.set_status("Getting scores...")
    res = Result(queue=Queue(), scores=None)
    scores = scores.copy()

    def do_work(st, next_st):
        try:
            score = compute_score(st)
            if score is not None:
                pos = bisect_left(scores, score)
                res.queue.put_nowait(QueuedScore(position=pos, score=score,
                                                 state=st, next_state=next_st))
                scores.insert(pos, score)
        except Exception:  # ignore current state in case of any problem
            pass
        res.scores = scores.copy()
        task.set_partial_result(res)

    state = None
    next_state = next(states)
    try:
        while True:
            if task.is_interruption_requested():
                return res
            task.set_progress_value(int(progress * 100 / max(1, state_count)))
            progress += 1
            state = copy.copy(next_state)
            next_state = copy.copy(next(states))
            do_work(state, next_state)
    except StopIteration:
        do_work(state, None)
    return res


class VizRankDialogAttr(VizRankDialog):
    """
    VizRank dialog for single attributes. The class provides most of the
    needed methods, except for `initialize` which is expected to store a
    list of `Variable` instances to `self.attrs`, and method
    `compute_score(state)` for scoring the combinations.

    The state is an attribute index.

    When the user selects an attribute, the dialog emits signal
    `selectionChanged` with the attribute as parameter.
    """

    attrSelected = Signal(Variable, Variable)
    _AttrRole = next(gui.OrangeUserRole)

    def __init__(self, master):
        super().__init__(master)
        self.attrs = []

    def sizeHint(self):
        """Assuming a single columns in the table, return `QSize(160, 512)` as
        a reasonable default size."""
        return QSize(160, 512)

    def check_preconditions(self):
        """Refuse ranking if there are no features or instances."""
        can_rank = self.master.data is not None and \
            self.master.data.domain.attributes and \
            len(self.master.data) != 0
        self.Information.nothing_to_rank(shown=not can_rank)
        return can_rank

    def on_selection_changed(self, selected, deselected):
        if not selected.isEmpty():
            attr = selected.indexes()[0].data(self._AttrRole)
            self.attrSelected.emit(attr)

    def state_count(self):
        return len(self.attrs)

    def iterate_states(self, initial_state):
        yield from range(initial_state or 0, len(self.attrs))

    def row_for_state(self, score, state):
        attr = self.attrs[state]
        item = QStandardItem(attr.name)
        item.setData(attr, self._AttrRole)
        return [item]


class VizRankDialogAttrPair(VizRankDialog):
    """
    VizRank dialog for pairs of attributes. The class provides most of the
    needed methods, except for `initialize` which is expected to store a
    list of `Variable` instances to `self.attrs`, and method
    `compute_score(state)` for scoring the combinations.

    The state is a pair of indices into `self.attrs`.

    When the user selects a pair, the dialog emits signal `selectionChanged`
    with a tuple of variables as parameter.
    """

    pairSelected = Signal(Variable, Variable)
    _AttrRole = next(gui.OrangeUserRole)

    def __init__(self, master):
        VizRankDialog.__init__(self, master)
        self.resize(320, 512)
        self.attrs = []
        manual_change_signal = getattr(master, "xy_changed_manually", None)
        if manual_change_signal:
            manual_change_signal.connect(self.on_manual_change)

    def sizeHint(self):
        """Assuming two columns in the table, return `QSize(320, 512)` as
        a reasonable default size."""
        return QSize(320, 512)

    def check_preconditions(self):
        """Refuse ranking if there are less than two feature or instances."""
        can_rank = self.master.data is not None and \
            len(self.master.data.domain.attributes) >= 2 and \
            len(self.master.data) >= 2
        self.Information.nothing_to_rank(shown=not can_rank)
        return can_rank

    def on_selection_changed(self, selected, deselected):
        selection = selected.indexes()
        if not selection:
            return
        attrs = selected.indexes()[0].data(self._AttrRole)
        self.selectionChanged.emit(attrs)

    def on_manual_change(self, attr1, attr2):
        model = self.rank_model
        self.rank_table.selectionModel().clear()
        for row in range(model.rowCount()):
            a1, a2 = model.data(model.index(row, 0), self._AttrRole)
            if a1 is attr1 and a2 is attr2:
                self.rank_table.selectRow(row)
                return

    def state_count(self):
        n_attrs = len(self.attrs)
        return n_attrs * (n_attrs - 1) / 2

    def iterate_states(self, initial_state):
        si, sj = initial_state or (0, 0)
        for i in range(si, len(self.attrs)):
            for j in range(sj, i):
                yield i, j
            sj = 0

    def row_for_state(self, score, state):
        attrs = sorted((self.attrs[x] for x in state), key=attrgetter("name"))
        item = QStandardItem(", ".join(a.name for a in attrs))
        item.setData(attrs, self._AttrRole)
        return [item]


class CanvasText(QGraphicsTextItem):
    """QGraphicsTextItem with more convenient constructor

       Args:
           scene (QGraphicsScene): scene into which the text is placed
           text (str): text; see also argument `html_text` (default: `""`)
           x (int): x-coordinate (default: 0)
           y (int): y-coordinate (default: 0)
           alignment (Qt.Alignment): text alignment
               (default: Qt.AlignLeft | Qt.AlignTop)
           bold (bool): if `True`, font is set to bold (default: `False`)
           font (QFont): text font
           z (int): text layer
           html_text (str): text as html; if present (default is `None`),
               it overrides the `text` argument
           tooltip (str): text tooltip
           show (bool): if `False`, the text is hidden (default: `True`)
           vertical (bool): if `True`, the text is rotated by 90 degrees
               (default: `False`)
    """
    def __init__(self, scene, text="", x=0, y=0,
                 alignment=Qt.AlignLeft | Qt.AlignTop, bold=False, font=None,
                 z=0, html_text=None, tooltip=None, show=True, vertical=False,
                 max_width=None):
        QGraphicsTextItem.__init__(self, text, None)

        if font:
            self.setFont(font)
        if bold:
            font = self.font()
            font.setBold(bold)
            self.setFont(font)
        if html_text:
            self.setHtml(html_text)

        self.alignment = alignment
        self.vertical = vertical
        if vertical:
            self.setRotation(-90)

        self.setPos(x, y)
        self.x, self.y = x, y
        self.setZValue(z)
        if tooltip:
            self.setToolTip(tooltip)
        if max_width is not None:
            assert not html_text
            self.elide(max_width)

        if show:
            self.show()
        else:
            self.hide()

        if scene is not None:
            scene.addItem(self)

    def elide(self, max_width):
        if self.boundingRect().width() <= max_width:
            return
        short = self.toPlainText()
        if not self.toolTip():
            self.setToolTip(short)
        while short and self.boundingRect().width() > max_width:
            short = short[:-1]
            self.setPlainText(short + "...")
            # apparently this has to be called to reset position
            self.setPos(self.x, self.y)

    def setPos(self, x, y):
        """setPos with adjustment for alignment"""
        self.x, self.y = x, y
        rect = QGraphicsTextItem.boundingRect(self)
        if self.vertical:
            h, w = rect.height(), rect.width()
            rect.setWidth(h)
            rect.setHeight(-w)
        if int(self.alignment & Qt.AlignRight):
            x -= rect.width()
        elif int(self.alignment & Qt.AlignHCenter):
            x -= rect.width() / 2.
        if int(self.alignment & Qt.AlignBottom):
            y -= rect.height()
        elif int(self.alignment & Qt.AlignVCenter):
            y -= rect.height() / 2.
        QGraphicsTextItem.setPos(self, x, y)


class CanvasRectangle(QGraphicsRectItem):
    """QGraphicsRectItem with more convenient constructor

    Args:
        scene (QGraphicsScene): scene into which the rectangle is placed
        x (int): x-coordinate (default: 0)
        y (int): y-coordinate (default: 0)
        width (int): rectangle's width (default: 0)
        height (int): rectangle's height (default: 0)
        z (int): z-layer
        pen (QPen): pen for the border; if present, it overrides the separate
            arguments for color, width and style
        pen_color (QColor or QPen): the (color of) the pen
            (default: `QColor(128, 128, 128)`)
        pen_width (int): pen width
        pen_style (PenStyle): pen style (default: `Qt.SolidLine`)
        brush_color (QColor): the color for the interior (default: same as pen)
        tooltip (str): tooltip
        show (bool): if `False`, the text is hidden (default: `True`)
        onclick (callable): callback for mouse click event
    """

    def __init__(self, scene, x=0, y=0, width=0, height=0,
                 pen_color=QColor(128, 128, 128), brush_color=None, pen_width=1,
                 z=0, pen_style=Qt.SolidLine, pen=None, tooltip=None, show=True,
                 onclick=None):
        super().__init__(x, y, width, height, None)
        self.onclick = onclick
        if brush_color:
            self.setBrush(QBrush(brush_color))
        if pen:
            self.setPen(pen)
        else:
            self.setPen(QPen(QBrush(pen_color), pen_width, pen_style))
        self.setZValue(z)
        if tooltip:
            self.setToolTip(tooltip)
        if show:
            self.show()
        else:
            self.hide()

        if scene is not None:
            scene.addItem(self)

    def mousePressEvent(self, event):
        if self.onclick:
            self.onclick(self, event)


class ViewWithPress(QGraphicsView):
    """QGraphicsView with a callback for mouse press event. The callback
    is given as keyword argument `handler`.
    """
    def __init__(self, *args, **kwargs):
        self.handler = kwargs.pop("handler")
        super().__init__(*args)

    def mousePressEvent(self, event):
        super().mousePressEvent(event)
        if not event.isAccepted():
            self.handler()

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user