From 03ad8c61dfc8522e09f5770f36e0f7d402f68fe3 Mon Sep 17 00:00:00 2001 From: Jaka Date: Tue, 6 Dec 2022 14:08:10 +0100 Subject: [PATCH] owkaplanmeier, owcohorts: replace get_column_view with get_column --- .../survival_analysis/widgets/owchorts.py | 4 ++-- .../widgets/owkaplanmeier.py | 10 ++++---- .../widgets/tests/test_owkaplanmeier.py | 24 ++++++++----------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/orangecontrib/survival_analysis/widgets/owchorts.py b/orangecontrib/survival_analysis/widgets/owchorts.py index a0ec361..fc4651a 100644 --- a/orangecontrib/survival_analysis/widgets/owchorts.py +++ b/orangecontrib/survival_analysis/widgets/owchorts.py @@ -76,8 +76,8 @@ def check_unique_values(split_by, values): cutoff = partial(check_unique_values, np.mean) elif splitting_criteria == SplittingCriteria.LogRankTest: time_var, event_var = get_survival_endpoints(data.domain) - durations, _ = data.get_column_view(time_var) - events, _ = data.get_column_view(event_var) + durations = data.get_column(time_var) + events = data.get_column(event_var) cutoff = partial(cutoff_by_log_rank_optimization, durations, events, callback) else: raise ValueError('Unknown splitting criteria') diff --git a/orangecontrib/survival_analysis/widgets/owkaplanmeier.py b/orangecontrib/survival_analysis/widgets/owkaplanmeier.py index fe0fd56..701c5e9 100644 --- a/orangecontrib/survival_analysis/widgets/owkaplanmeier.py +++ b/orangecontrib/survival_analysis/widgets/owkaplanmeier.py @@ -658,11 +658,11 @@ def generate_plot_curves(self) -> List[EstimatedFunctionCurve]: return [] data = self.data - time, _ = data.get_column_view(self.time_var) - events, _ = data.get_column_view(self.event_var) + time = data.get_column(self.time_var) + events = data.get_column(self.event_var) if self.group_var: - groups, _ = data.get_column_view(self.group_var.name) + groups = data.get_column(self.group_var.name) group_indexes = [index for index, _ in enumerate(self.group_var.values)] colors = [self._get_discrete_var_color(index) for index in group_indexes] masks = groups == np.reshape(group_indexes, (-1, 1)) @@ -688,7 +688,7 @@ def commit(self): data = self.data - time, _ = data.get_column_view(self.time_var) + time = data.get_column(self.time_var) if self.group_var is None: time_interval = self.graph.selection[0].x start, end = time_interval[0], time_interval[-1] @@ -697,7 +697,7 @@ def commit(self): ) else: selection = [] - group, _ = data.get_column_view(self.group_var.name) + group = data.get_column(self.group_var.name) for group_id, time_interval in self.graph.selection.items(): start, end = time_interval.x[0], time_interval.x[-1] selection += ( diff --git a/orangecontrib/survival_analysis/widgets/tests/test_owkaplanmeier.py b/orangecontrib/survival_analysis/widgets/tests/test_owkaplanmeier.py index 806dcfc..4013c38 100644 --- a/orangecontrib/survival_analysis/widgets/tests/test_owkaplanmeier.py +++ b/orangecontrib/survival_analysis/widgets/tests/test_owkaplanmeier.py @@ -85,12 +85,8 @@ def setUp(self) -> None: vb.resize(200, 200) def simulate_mouse_drag(self, start: tuple, end: tuple): - start = self.widget.graph.view_box.mapViewToScene( - pg.Point(start[0], start[1]) - ).toPoint() - end = self.widget.graph.view_box.mapViewToScene( - pg.Point(end[0], end[1]) - ).toPoint() + start = self.widget.graph.view_box.mapViewToScene(pg.Point(start[0], start[1])) + end = self.widget.graph.view_box.mapViewToScene(pg.Point(end[0], end[1])) mouse_move(self.widget.graph, start) # this is somehow not respected in KaplanMeierViewBox.mouseDragEvent @@ -166,13 +162,13 @@ def test_curve_highlight(self): self.widget.group_var = self.widget.data.domain['Group'] self.widget.on_group_changed() - pos = self.widget.graph.view_box.mapViewToScene(pg.Point(1.5, 0.5)).toPoint() + pos = self.widget.graph.view_box.mapViewToScene(pg.Point(1.5, 0.5)) mouse_move(self.widget.graph, pos) # We need to wait for events to process QTest.qWait(100) self.assertTrue(self.widget.graph.highlighted_curve == 1) - pos = self.widget.graph.view_box.mapViewToScene(pg.Point(1.5, 0.85)).toPoint() + pos = self.widget.graph.view_box.mapViewToScene(pg.Point(1.5, 0.85)) mouse_move(self.widget.graph, pos) QTest.qWait(100) self.assertTrue(self.widget.graph.highlighted_curve == 0) @@ -197,9 +193,9 @@ def test_selection(self): # check output data selected_data = self.get_output(self.widget.Outputs.selected_data) - selected_groups = selected_data.get_column_view('Group')[0] + selected_groups = selected_data.get_column('Group') self.assertEqual(12, selected_groups.size) - selected_groups = set(selected_data.get_column_view('Group')[0]) + selected_groups = set(selected_data.get_column('Group')) self.assertEqual(2, len(selected_groups)) self.assertIn(0, selected_groups) self.assertIn(1, selected_groups) @@ -223,9 +219,9 @@ def test_selection(self): # check output data selected_data = self.get_output(self.widget.Outputs.selected_data) - selected_groups = selected_data.get_column_view('Group')[0] + selected_groups = selected_data.get_column('Group') self.assertEqual(6, selected_groups.size) - selected_groups = set(selected_data.get_column_view('Group')[0]) + selected_groups = set(selected_data.get_column('Group')) self.assertEqual(1, len(selected_groups)) self.assertIn(0, selected_groups) self.assertNotIn(1, selected_groups) @@ -249,9 +245,9 @@ def test_selection(self): # check output data selected_data = self.get_output(self.widget.Outputs.selected_data) - selected_groups = selected_data.get_column_view('Group')[0] + selected_groups = selected_data.get_column('Group') self.assertEqual(6, selected_groups.size) - selected_groups = set(selected_data.get_column_view('Group')[0]) + selected_groups = set(selected_data.get_column('Group')) self.assertEqual(1, len(selected_groups)) self.assertIn(1, selected_groups) self.assertNotIn(0, selected_groups)