Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Concordance: selection settings #249

Merged
merged 2 commits into from
Sep 8, 2017
Merged

[FIX] Concordance: selection settings #249

merged 2 commits into from
Sep 8, 2017

Conversation

jerneju
Copy link
Contributor

@jerneju jerneju commented May 22, 2017

Issue

Fixes #217.

Description of changes
Includes
  • Code changes
  • Tests
  • Documentation

@codecov-io
Copy link

codecov-io commented May 22, 2017

Codecov Report

Merging #249 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #249   +/-   ##
=======================================
  Coverage   85.04%   85.04%           
=======================================
  Files          34       34           
  Lines        1825     1825           
  Branches      333      333           
=======================================
  Hits         1552     1552           
  Misses        238      238           
  Partials       35       35

autocommit = Setting(True)
context_width = Setting(5)
word = Setting("")
# TODO Set selection settings.
word = ContextSetting("b", exclude_metas=False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is "b" the default? Please set it to an empty string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the widget is still WIP, I have not done the cleaning yet. Anyway thanks for the comments.

@@ -85,7 +85,7 @@ def flags(self, _):
return Qt.ItemIsEnabled | Qt.ItemIsSelectable

def rowCount(self, parent=None, *args, **kwargs):
return 0 if parent.isValid() or self.word_index is None \
return 0 if parent and parent.isValid() or self.word_index is None \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still fails if I select some documents in Concordance and then remove the data. It is fixed in #232.

@@ -223,11 +227,15 @@ def set_width(self):
QItemSelectionModel.SelectCurrent | QItemSelectionModel.Rows)

def set_corpus(self, data=None):
self.closeContext()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While at it, would it not make sense to remove the empty line? Or is this intentional?

self.corpus = data
if data is not None and not isinstance(data, Corpus):
self.corpus = Corpus.from_table(data.domain, data)
self.model.set_corpus(self.corpus)
self.update_widget()
self.openContext(self.corpus)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

else:
self.send("Selected Documents", None)


def get_selection(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably nitpicking, but perhaps we should move the two selection methods to line 229? Just trying to keep with the structure of the rest of the Text widgets. :)
Also, please remove the double empty lines above and keep double empty lines only before if name.

@jerneju jerneju changed the title [WIP][FIX] Concordance: settings [FIX] Concordance: settings May 25, 2017
@ajdapretnar
Copy link
Collaborator

Doh, sorry, I didn't see the tag. 🙈 Silly me.
I was just in a hurry to merge EVERYTHING!! 🤸‍♂️ 🤣

@ajdapretnar
Copy link
Collaborator

ajdapretnar commented May 26, 2017

So is this done or do we wait for similar fixes as in #241 (list issue)?
+ I think this needs a rebase?

@jerneju
Copy link
Contributor Author

jerneju commented May 26, 2017

Rebased.

@ajdapretnar
Copy link
Collaborator

@nikicc Please check as well and merge. :)

@@ -235,12 +239,32 @@ def set_width(self):
self.conc_view.selectionModel().select(sel,
QItemSelectionModel.SelectCurrent | QItemSelectionModel.Rows)

def get_selection(self):
sel = self.conc_view.selectionModel().selection()
selection = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just:

selection = sorted(set(cell.row() for cell in sel.indexes()))

@@ -256,7 +280,7 @@ def set_word_from_input(self, topic):
def set_word(self):
self.model.set_word(self.word)
self.update_widget()
self.commit()
self.set_selection()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this? Currently, if I am inputing different words on input the selection persists which is kind on unintuitive?

@jerneju
Copy link
Contributor Author

jerneju commented Jun 1, 2017

Rows selection not finished yet. Waiting forDataHashContextHandlerto be implemented. Similar problem as in #255 .

@nikicc
Copy link
Contributor

nikicc commented Jun 1, 2017

We should probably do the same for #256 to avoid problems with selection being stored in context settings.

@jerneju jerneju changed the title [FIX] Concordance: settings [WIP][FIX] Concordance: selection settings Jun 1, 2017
@ajdapretnar
Copy link
Collaborator

@jerneju What is the state of this PR? Is it still WIP? Can we expect to merge soon?

@jerneju
Copy link
Contributor Author

jerneju commented Jul 13, 2017

@ajdapretnar: It is still impossible to implement this since we cannot do it without proper context handler. See my comment above.

@ajdapretnar
Copy link
Collaborator

Ok, next step. Is anyone working on the context handler? If not, should we assign? It would be great to finish this before the workshop.

@jerneju jerneju changed the title [WIP][FIX] Concordance: selection settings [FIX] Concordance: selection settings Aug 31, 2017
@@ -173,7 +173,7 @@ class Outputs:
autocommit = Setting(True)
context_width = Setting(5)
word = ContextSetting("", exclude_metas=False)
# TODO Set selection settings (DataHashContextHandler)
selection = Setting([0], schema_only=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we automatically select the first item? Shouldn't we leave the selection empty by defult?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... Perhaps you are right. Selecting the first item only makes sense in Corpus Viewer, but not in Concordance. I'm sorry, this is probably my fault as I said to make it the same as CV.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let it be empty.

if self.corpus:
self._set_selection(selection)
else:
self._set_selection([0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, why do we set [0] as selection if there is no corpus?

def handleNewSignals(self):
selection = self.selection
if self.corpus:
self._set_selection(selection)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self._set_selection(self.selection)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

def _save_selection(self):
sel = self.conc_view.selectionModel().selection()
selection = sorted(set(cell.row() for cell in sel.indexes()))
if selection:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this if?

@nikicc
Copy link
Contributor

nikicc commented Sep 1, 2017

@jerneju I added some code that clears selections when words on input change and also did some refactoring. Please check, if everything is OK.

Perhaps, @ajdapretnar can you also check this one more time?

self.set_word()

@Inputs.query_word
def set_word_from_input(self, topic):
self.Warning.multiple_words_on_input.clear()
if self.is_word_on_input: # word changed, clear selection
self.selected_rows = []
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why if?

Copy link
Contributor

@nikicc nikicc Sep 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it only resets when we change the input word from one topic to another and not also when we reload the scema and topic is passed on input.

I think that without this when reloading, the selection would be reset before handleNewSignals would have the chance to set it.

@@ -259,17 +255,21 @@ def _set_selection(self, selection):
def set_corpus(self, data=None):
self.closeContext()
self.corpus = data
if data is not None and not isinstance(data, Corpus):
self.corpus = Corpus.from_table(data.domain, data)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these two lines should not have been removed. Now the test fails.

@nikicc
Copy link
Contributor

nikicc commented Sep 8, 2017

@jerneju I removed the test that doesn't apply anymore. Should be fine now.

@jerneju jerneju merged commit 0524376 into biolab:master Sep 8, 2017
@jerneju jerneju deleted the concordance-settings branch September 8, 2017 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants