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: problem when closing settings fig #85

Merged
merged 32 commits into from
Apr 8, 2022

Conversation

juangpc
Copy link
Contributor

@juangpc juangpc commented Mar 31, 2022

Hi,

This PR attempts to fix #78 (opened by @jasmainak).

There are two small problems/typos and a QEvent object which is not sent to the closeEvent call.

@juangpc juangpc changed the title fix typo in _toggle_help_fig FIX: problem when closing settings fig Apr 1, 2022
@agramfort
Copy link
Member

I confirm it fixes the problem. Any chance we could add a test for this?

thx @juangpc !

@juangpc
Copy link
Contributor Author

juangpc commented Apr 4, 2022

Thank you.
Yes, I'll see what I can do to test this menu interaction.

@juangpc
Copy link
Contributor Author

juangpc commented Apr 5, 2022

Hello again,

Following @agramfort comment, I'm trying to provide additional test coverage.

The tests I've added would've shattered the original issue (#78) so that is progress. However there are some comments, questions I'd like to share:

  • I'm trying to keep all the structure of the code as I see it now. I see that functionality of the mne-qt-browser is now being tested in the test_raw.py script inside the mne-python repo. Although some helpers functions are added as members to the class PyQtGraphBrowser which is in _py_figure.py inside the mne-qt-browser repo.
    Even in this repository documentation, when explaining how to do the tests, one needs to go to run them to the mne-python repository. So I'm trying to follow this structure.
  • There are thus two linked necessary PRs. One being this one, and a second one on the mne-python repo. I haven't created it yet. I'll wait to see what is best. It will come from this branch on my fork. Should I create it?
  • I've added the mark pgtest so that it doesn't interact with the matplotlib related classes. Is this correct?
  • I've added the QTest dependency for the test_raw.py script in mne-python repo. Is this ok? It works in my env.
  • Added additional tests to cover all the members (QActions) on the toolbar of the mne-qt-browser. Should I create a separate PR?
  • None of my branches are rebased. Should I? I hear you guys rebase and later squash. Checked the documentation and contribution guide I couldn't find anything related.
  • This PR, and any later one, will probably be marked as "Allow edits by maintainers". Please, feel free to edit the code in my fork. No problem at all.

Thanks.

@agramfort
Copy link
Member

@juangpc can you link the PR here I don't see it?

there are some tests run here. Any chance to add a test here?

@juangpc
Copy link
Contributor Author

juangpc commented Apr 7, 2022

Hi,

Thanks for your mention @hoechenberger.

  • I (think I) have followed @agramfort guidance to place here all the tests. I've increased the intensity and granularity with which the GUI components are tested. My intention is to eventually lead to a 100% coverage.

  • There is this sensitivity slider in the settings dialog issue I've created (Sensitivity slider in Settings window #103). I don't know exactly what it is supposed to do, but it doesn't seem to be doing too much. The effect is similar to widening the shown time span. In any case, the test, does test the slider as a GUI component, and its effect in the model. This component is neighboring the Settings dialog, which is the original subject of this PR. I think it can belong to the same PR.

  • I've added a ',' comma shortcut for the settings dialog. It was quite useful during development and I figure it might become useful for the user. Many SW applications use this shortcut for settings. (Again) feel free to delete this shortcut. No hurt feelings.

  • Changed the order of the subsampling methods because 'mean' seems more convenient as a default method, (index 0).

  • Since the tests are now migrating towards this repository, I've edited the README file too.

Thanks,

@juangpc
Copy link
Contributor Author

juangpc commented Apr 7, 2022

Ready for merge on my side.

@hoechenberger
Copy link
Member

hoechenberger commented Apr 7, 2022

Hello @juangpc, thanks for the effort you're putting in here!!

I'm just a little concerned this work is getting a bit outside of the scope of the original idea of this PR, and I wonder if it would make sense to split it into smaller, separate PRs that each basically do one thing only. This will make the review process faster and easier, and allows for a better discussion of the individual changes you're proposing!

For example, while I do like the idea of adding a shortcut for settings, it should conform to the system standards, e.g. Cmd+, on macOS, and to whatever the defaults might be on Windows and Linux.

@juangpc
Copy link
Contributor Author

juangpc commented Apr 7, 2022 via email

Comment on lines 6 to 7
import numpy as np
import math
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import numpy as np
import math
import math
import numpy as np

import standard lib first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

with later changes math lib no longer needed.

mne_qt_browser/tests/test_pg_specific.py Show resolved Hide resolved
@@ -1697,10 +1697,10 @@ def __init__(self, main, **kwargs):
class ProjDialog(_BaseDialog):
"""A dialog to toggle projections."""

def __init__(self, main, *, name):
def __init__(self, main, title='Projectors', **kwargs):
Copy link
Member

@hoechenberger hoechenberger Apr 7, 2022

Choose a reason for hiding this comment

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

Why do we need the flexibility to adjust the title of that dialog?

Also, in #101 I specifically changed the signature to not accept kwargs and instead enforce passing keyword-only arguments to ensure better code health. Please revert your change to this line

Copy link
Member

Choose a reason for hiding this comment

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

this one also needs to be reverted. We really try to avoid kwargs in mne as it makes the code super hard to document and test.

Copy link
Member

Choose a reason for hiding this comment

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

I spent some time looking at the code with @juangpc and I agree **kwargs made the code really hard to read. And it's nested really deep with the backend handling. What used to be "params" in the past is now "kwargs"

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 see. Well. I'm sorry. I'll fix this.

Why do we need the flexibility to adjust the title of that dialog?

I don't need it. I changed it back because: 1. coherence. 2. your code when improperly merged with mine, introduced a bug.
Attending 1) there are 5 or so dialog windows child classes to _BaseDialog. And the way the child classes communicate with it in the other instances is different from what you proposed in your change. See SettingsDialog or HelpDialog, all go in the same toolbar.
Attending 2) The merge with your change introduced a bug in my fork. It might have been me or automatic merge. Don't remember, it was late. This has been solved now. I was surprised by your change, the tests found it. The tests I push here, actually found the bug. So I guess thats a good thing. Anyway it was a bad merge. I'll fix this.

Also, I get a warning when using name as argument in line 1700: "Shadows name 'name' from greater scope".

I don't know the difference between single star "*" and "**kwargs". This is my first python pr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Attended: 0408af1

self.external_change = True
# Create projection-layout
super().__init__(main.window(), name=name, title='Projectors')
super().__init__(main.window(), title=title, **kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

See above, please revert this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Attended 0408af1

@@ -1697,10 +1697,10 @@ def __init__(self, main, **kwargs):
class ProjDialog(_BaseDialog):
"""A dialog to toggle projections."""

def __init__(self, main, *, name):
def __init__(self, main, title='Projectors', **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

@juangpc you need to be careful when making large changes including to public functions. One PR should be on one feature / one bug.

Why do you need these changes to address the fix aimed at here? If it's not related to the fix can you revert the unrelated changes and put this in a follow up PR that can be discussed with the other devs?

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 do you need these changes to address the fix aimed at here?

I don't. Attended here: 0408af1

@@ -1578,7 +1578,7 @@ def __init__(self, main, title='Settings', **kwargs):
'<i>(Those methods are adapted from '
'pyqtgraph)</i><br>'
'Default is "peak".')
self.ds_method_cmbx.addItems(['subsample', 'mean', 'peak'])
self.ds_method_cmbx.addItems(['mean', 'subsample', 'peak'])
Copy link
Member

Choose a reason for hiding this comment

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

this is unrelated right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

clearly unrelated to the crash. Attended here: 798c39d

@juangpc
Copy link
Contributor Author

juangpc commented Apr 7, 2022

Ready on my side.

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

Other than a couple of small suggestions, LGTM!

mne_qt_browser/tests/test_pg_specific.py Outdated Show resolved Hide resolved
mne_qt_browser/tests/test_pg_specific.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@juangpc
Copy link
Contributor Author

juangpc commented Apr 8, 2022

Ready on my side.

Since this is getting close to ready for merging. Let me thank you all for your time. Hope this is useful.

@agramfort
Copy link
Member

@larsoner I let you merge if happy

@larsoner larsoner merged commit 3d3b199 into mne-tools:main Apr 8, 2022
@larsoner
Copy link
Member

larsoner commented Apr 8, 2022

Thanks @juangpc !

@juangpc juangpc deleted the fix_settings_menu_crash branch April 8, 2022 22:37
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.

closing settings dialog gives error
5 participants