Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimozGodec committed Aug 25, 2021
1 parent 9876151 commit d4a8fd4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 29 deletions.
11 changes: 10 additions & 1 deletion orangecontrib/text/widgets/owscoredocuments.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,19 @@ def _fill_table(self) -> None:
labels = ["Document"] + labels
titles = self.corpus.titles.tolist()

# clearing selection and sorting to prevent SEGFAULT on model.wrap
self.view.horizontalHeader().setSortIndicator(-1, Qt.AscendingOrder)
self.view.clearSelection()

self.model.wrap([[c] + s for c, s in zip(titles, scores.tolist())])
self.model.setHorizontalHeaderLabels(labels)
self.view.update_column_widths()
self.view.horizontalHeader().setSortIndicator(*self.sort_column_order)
if self.model.columnCount() > self.sort_column_order[0]:
# if not enough columns do not apply sorting from settings since
# sorting can besaved for score column while scores are still computing
# tables is filled before scores are computed with document names
self.view.horizontalHeader().setSortIndicator(*self.sort_column_order)

self._select_rows()

def _fill_and_output(self) -> None:
Expand Down
59 changes: 31 additions & 28 deletions orangecontrib/text/widgets/tests/test_owscoredocuments.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,38 +292,41 @@ def test_sort_setting(self):
"""
view = self.widget.view
model = view.model()
self.send_signal(self.widget.Inputs.corpus, self.corpus)
self.send_signal(self.widget.Inputs.words, self.words)
self.wait_until_finished()

self.widget.sort_column_order = (1, Qt.DescendingOrder)
self.widget._fill_table()
self.wait_until_finished()

header = self.widget.view.horizontalHeader()
current_sorting = (header.sortIndicatorSection(), header.sortIndicatorOrder())
data = [model.data(model.index(i, 1)) for i in range(model.rowCount())]
self.assertTupleEqual((1, Qt.DescendingOrder), current_sorting)
self.assertListEqual(sorted(data, reverse=True), data)

self.send_signal(self.widget.Inputs.words, None)
self.send_signal(self.widget.Inputs.words, self.words)
self.wait_until_finished()

header = self.widget.view.horizontalHeader()
current_sorting = (header.sortIndicatorSection(), header.sortIndicatorOrder())
data = [model.data(model.index(i, 1)) for i in range(model.rowCount())]
self.assertTupleEqual((1, Qt.DescendingOrder), current_sorting)
self.assertListEqual(sorted(data, reverse=True), data)

self.send_signal(self.widget.Inputs.corpus, None)
self.send_signal(self.widget.Inputs.words, None)
self.send_signal(self.widget.Inputs.corpus, self.corpus)
self.send_signal(self.widget.Inputs.words, self.words)
self.wait_until_finished()
#
# header = self.widget.view.horizontalHeader()
# current_sorting = (header.sortIndicatorSection(), header.sortIndicatorOrder())
# data = [model.data(model.index(i, 1)) for i in range(model.rowCount())]
# self.assertTupleEqual((1, Qt.DescendingOrder), current_sorting)
# self.assertListEqual(sorted(data, reverse=True), data)

# self.send_signal(self.widget.Inputs.words, None)
# self.send_signal(self.widget.Inputs.words, self.words)
# self.wait_until_finished()
#
# header = self.widget.view.horizontalHeader()
# current_sorting = (header.sortIndicatorSection(), header.sortIndicatorOrder())
# data = [model.data(model.index(i, 1)) for i in range(model.rowCount())]
# self.assertTupleEqual((1, Qt.DescendingOrder), current_sorting)
# self.assertListEqual(sorted(data, reverse=True), data)
#
# self.send_signal(self.widget.Inputs.corpus, None)
# self.send_signal(self.widget.Inputs.words, None)
# self.send_signal(self.widget.Inputs.corpus, self.corpus)
# self.send_signal(self.widget.Inputs.words, self.words)
# self.wait_until_finished()
#
# header = self.widget.view.horizontalHeader()
# current_sorting = (header.sortIndicatorSection(), header.sortIndicatorOrder())
# data = [model.data(model.index(i, 1)) for i in range(model.rowCount())]
# self.assertTupleEqual((1, Qt.DescendingOrder), current_sorting)
# self.assertListEqual(sorted(data, reverse=True), data)

header = self.widget.view.horizontalHeader()
current_sorting = (header.sortIndicatorSection(), header.sortIndicatorOrder())
data = [model.data(model.index(i, 1)) for i in range(model.rowCount())]
self.assertTupleEqual((1, Qt.DescendingOrder), current_sorting)
self.assertListEqual(sorted(data, reverse=True), data)

def test_selection_none(self):
self.send_signal(self.widget.Inputs.corpus, self.corpus)
Expand Down

0 comments on commit d4a8fd4

Please sign in to comment.