From 3ccb6c0d6810f95b0ee22568e0bbefb24b3cd9d7 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 11 Feb 2022 11:14:33 -0500 Subject: [PATCH] API: Change name to qt (#10323) * API: Change name to qt * FIX: Links [skip azp] [skip actions] --- azure-pipelines.yml | 2 +- doc/changes/latest.inc | 2 ++ mne/conftest.py | 6 ++-- mne/utils/docs.py | 6 ++-- mne/viz/_figure.py | 62 ++++++++++++++++++++------------------ mne/viz/backends/_utils.py | 2 +- mne/viz/raw.py | 8 ++--- mne/viz/tests/test_raw.py | 14 ++++----- mne/viz/utils.py | 2 +- 9 files changed, 55 insertions(+), 49 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d351915ef0f..2bc4a707b7f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -127,7 +127,7 @@ stages: - script: python -c "import mne; mne.datasets.testing.data_path(verbose=True)" displayName: 'Get test data' - script: pytest -m "ultraslowtest or pgtest" --tb=short --cov=mne --cov-report=xml --cov-report=html -vv mne - displayName: 'Run ultraslow and PyQtGraph mne-qt-browser tests' + displayName: 'Run ultraslow and mne-qt-browser tests' - bash: bash <(curl -s https://codecov.io/bash) displayName: 'Codecov' condition: succeededOrFailed() diff --git a/doc/changes/latest.inc b/doc/changes/latest.inc index d025b4649ca..b96f5b5b538 100644 --- a/doc/changes/latest.inc +++ b/doc/changes/latest.inc @@ -199,6 +199,8 @@ API changes - The ``verbose`` attribute of classes (e.g., :class:`mne.io.Raw`, `mne.Epochs`, etc.) has been deprecated. Explicitly pass ``verbose`` to methods as necessary instead. (:gh:`10267` by `Eric Larson`_) +- In :func:`mne.viz.set_browser_backend`, the `mne-qt-browser `__-based backend is now called ``'qt'`` rather than ``'pyqtgraph'`` for simplicity (:gh:`10323` by `Eric Larson`_) + Dependencies ~~~~~~~~~~~~ Numerous external dependencies that used to be bundled with MNE-Python are now diff --git a/mne/conftest.py b/mne/conftest.py index 59cb8e9c8a1..dad3feb1d37 100644 --- a/mne/conftest.py +++ b/mne/conftest.py @@ -408,19 +408,19 @@ def _check_pyqtgraph(): def pg_backend(garbage_collect): """Use for pyqtgraph-specific test-functions.""" _check_pyqtgraph() - with use_browser_backend('pyqtgraph') as backend: + with use_browser_backend('qt') as backend: yield backend backend._close_all() @pytest.fixture(params=[ 'matplotlib', - pytest.param('pyqtgraph', marks=pytest.mark.pgtest), + pytest.param('qt', marks=pytest.mark.pgtest), ]) def browser_backend(request, garbage_collect): """Parametrizes the name of the browser backend.""" backend_name = request.param - if backend_name == 'pyqtgraph': + if backend_name == 'qt': _check_pyqtgraph() with use_browser_backend(backend_name) as backend: yield backend diff --git a/mne/utils/docs.py b/mne/utils/docs.py index 4ac942ed96c..3fc28b4dd83 100644 --- a/mne/utils/docs.py +++ b/mne/utils/docs.py @@ -1575,7 +1575,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.24 """ -# Visualization with pyqtgraph +# Visualization with Qt docdict['precompute'] = """ precompute : bool | str Whether to load all data (not just the visible portion) into RAM and @@ -1583,7 +1583,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): processor thread, instead of window-by-window during scrolling. The default ``'auto'`` compares available RAM space to the expected size of the precomputed data, and precomputes only if enough RAM is available. ``True`` - and ``'auto'`` only work if using the PyQtGraph backend. + and ``'auto'`` only work if using the Qt backend. .. versionadded:: 0.24 """ @@ -1592,7 +1592,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): use_opengl : bool | None Whether to use OpenGL when rendering the plot (requires ``pyopengl``). May increase performance, but effect is dependent on system CPU and - graphics hardware. Only works if using the PyQtGraph backend. Default is + graphics hardware. Only works if using the Qt backend. Default is None, which will use False unless the user configuration variable ``MNE_BROWSER_USE_OPENGL`` is set to ``'true'``, see :func:`mne.set_config`. diff --git a/mne/viz/_figure.py b/mne/viz/_figure.py index 7e0d337b246..4f9f817756c 100644 --- a/mne/viz/_figure.py +++ b/mne/viz/_figure.py @@ -331,7 +331,7 @@ def _process_data(self, data, start, stop, picks, """Update self.mne.data after user interaction.""" # apply projectors if self.mne.projector is not None: - # thread is the loading-thread only available in pyqtgraph-backend + # thread is the loading-thread only available in Qt-backend if thread: thread.processText.emit('Applying Projectors...') data = self.mne.projector @ data @@ -618,6 +618,8 @@ def _get_browser(**kwargs): def _check_browser_backend_name(backend_name): _validate_type(backend_name, str, 'backend_name') + backend_name = backend_name.lower() + backend_name = 'qt' if backend_name == 'pyqtgraph' else backend_name _check_option('backend_name', backend_name, VALID_BROWSE_BACKENDS) return backend_name @@ -633,7 +635,9 @@ def set_browser_backend(backend_name, verbose=None): ---------- backend_name : str The 2D browser backend to select. See Notes for the capabilities - of each backend (``'matplotlib'``, ``'pyqtgraph'``). + of each backend (``'matplotlib'``, ``'qt'``). The ``'qt'`` browser + requires `mne-qt-browser + `__. %(verbose)s Returns @@ -649,32 +653,32 @@ def set_browser_backend(backend_name, verbose=None): .. table:: :widths: auto - +--------------------------------------+------------+-----------+ - | **2D browser function:** | matplotlib | pyqtgraph | - +======================================+============+===========+ - | :func:`plot_raw` | ✓ | ✓ | - +--------------------------------------+------------+-----------+ - | :func:`plot_epochs` | ✓ | | - +--------------------------------------+------------+-----------+ - | :func:`plot_ica_sources` | ✓ | | - +--------------------------------------+------------+-----------+ - +--------------------------------------+------------+-----------+ - | **Feature:** | - +--------------------------------------+------------+-----------+ - | Show Events | ✓ | ✓ | - +--------------------------------------+------------+-----------+ - | Add/Edit/Remove Annotations | ✓ | ✓ | - +--------------------------------------+------------+-----------+ - | Toggle Projections | ✓ | ✓ | - +--------------------------------------+------------+-----------+ - | Butterfly Mode | ✓ | ✓ | - +--------------------------------------+------------+-----------+ - | Selection Mode | ✓ | ✓ | - +--------------------------------------+------------+-----------+ - | Smooth Scrolling | | ✓ | - +--------------------------------------+------------+-----------+ - | Overview-Bar (with Z-Score-Mode) | | ✓ | - +--------------------------------------+------------+-----------+ + +--------------------------------------+------------+----+ + | **2D browser function:** | matplotlib | qt | + +======================================+============+====+ + | :func:`plot_raw` | ✓ | ✓ | + +--------------------------------------+------------+----+ + | :func:`plot_epochs` | ✓ | | + +--------------------------------------+------------+----+ + | :func:`plot_ica_sources` | ✓ | | + +--------------------------------------+------------+----+ + +--------------------------------------+------------+----+ + | **Feature:** | + +--------------------------------------+------------+----+ + | Show Events | ✓ | ✓ | + +--------------------------------------+------------+----+ + | Add/Edit/Remove Annotations | ✓ | ✓ | + +--------------------------------------+------------+----+ + | Toggle Projections | ✓ | ✓ | + +--------------------------------------+------------+----+ + | Butterfly Mode | ✓ | ✓ | + +--------------------------------------+------------+----+ + | Selection Mode | ✓ | ✓ | + +--------------------------------------+------------+----+ + | Smooth Scrolling | | ✓ | + +--------------------------------------+------------+----+ + | Overview-Bar (with Z-Score-Mode) | | ✓ | + +--------------------------------------+------------+----+ .. versionadded:: 0.24 """ @@ -742,7 +746,7 @@ def use_browser_backend(backend_name): Parameters ---------- - backend_name : {'matplotlib', 'pyqtgraph'} + backend_name : {'matplotlib', 'qt'} The 2D browser backend to use in the context. """ old_backend = set_browser_backend(backend_name) diff --git a/mne/viz/backends/_utils.py b/mne/viz/backends/_utils.py index 345fc2ce10f..bba4adead57 100644 --- a/mne/viz/backends/_utils.py +++ b/mne/viz/backends/_utils.py @@ -17,7 +17,7 @@ VALID_BROWSE_BACKENDS = ( 'matplotlib', - 'pyqtgraph' + 'qt', ) VALID_3D_BACKENDS = ( diff --git a/mne/viz/raw.py b/mne/viz/raw.py index 260a18feb5c..69cc06b264d 100644 --- a/mne/viz/raw.py +++ b/mne/viz/raw.py @@ -89,7 +89,7 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=20, Whether to halt program execution until the figure is closed. Useful for setting bad channels on the fly by clicking on a line. May not work on all systems / platforms. - (Only pyqtgraph) If you run from a script, this needs to + (Only Qt) If you run from a script, this needs to be ``True`` or a Qt-eventloop needs to be started somewhere else in the script (e.g. if you want to implement the browser inside another Qt-Application). @@ -193,9 +193,9 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=20, By default, the channel means are removed when ``remove_dc`` is set to ``True``. This flag can be toggled by pressing 'd'. - .. note:: For the pyqtgraph backend to run in IPython with ``block=False`` + .. note:: For the Qt backend to run in IPython with ``block=False`` you must run the magic command ``%%gui qt5`` first. - .. note:: To report issues with the pyqtgraph-backend, please use the + .. note:: To report issues with the qt-backend, please use the `issues `_ of ``mne-qt-browser``. """ @@ -346,7 +346,7 @@ def plot_raw(raw, events=None, duration=10.0, start=0.0, n_channels=20, scalebars_visible=show_scalebars, window_title=title, bgcolor=bgcolor, - # pyqtgraph-specific + # Qt-specific precompute=precompute, use_opengl=use_opengl) diff --git a/mne/viz/tests/test_raw.py b/mne/viz/tests/test_raw.py index 2dfc56b763c..75c8c3f7c26 100644 --- a/mne/viz/tests/test_raw.py +++ b/mne/viz/tests/test_raw.py @@ -59,7 +59,7 @@ def _annotation_helper(raw, browse_backend, events=False): fig._fake_click(xy, fig=ann_fig, ax=ann_fig.mne.radio_ax, xform='data') else: - # The modal dialogs of the pyqtgraph-backend would block the test, + # The modal dialogs of the Qt-backend would block the test, # thus a new description will be added programmatically. ann_fig._add_description('BAD test') @@ -272,7 +272,7 @@ def test_plot_raw_selection(raw, browser_backend): assert len(fig.mne.traces) == len(sel_dict['Misc']) # 1 # switch to butterfly mode fig._fake_keypress('b', fig=sel_fig) - # ToDo: For pyqtgraph-backend the framework around RawTraceItem makes + # ToDo: For Qt-backend the framework around RawTraceItem makes # it difficult to show the same channel multiple times which is why # it is currently not implemented. # This would be relevant if you wanted to plot several selections in @@ -318,7 +318,7 @@ def test_plot_raw_selection(raw, browser_backend): fig._click_ch_name(ch_index=1, button=1) # mark good assert lasso.ec[:, 0].sum() == 0 # all channels black # test lasso - # Testing lasso-interactivity of sensor-plot within pyqtgraph-backend + # Testing lasso-interactivity of sensor-plot within Qt-backend # with QTest doesn't seem to work. want = ['MEG 0121', 'MEG 0122', 'MEG 0123'] if ismpl: @@ -387,7 +387,7 @@ def test_plot_raw_child_figures(raw, browser_backend): # test child fig toggles _child_fig_helper(fig, '?', 'fig_help', browser_backend) _child_fig_helper(fig, 'j', 'fig_proj', browser_backend) - # In pyqtgraph, this is a dock-widget instead of a separated window. + # In Qt, this is a dock-widget instead of a separated window. if ismpl: _child_fig_helper(fig, 'a', 'fig_annotation', browser_backend) assert len(fig.mne.child_figs) == 0 # make sure the helper cleaned up @@ -478,7 +478,7 @@ def test_plot_raw_traces(raw, events, browser_backend): assert labels == [raw.ch_names[5], raw.ch_names[2], raw.ch_names[3]] for _ in (0, 0): # first click changes channels to mid; second time shouldn't change - # This needs to be changed for pyqtgraph, because there scrollbars are + # This needs to be changed for Qt, because there scrollbars are # drawn differently (value of slider at lower end, not at middle) yclick = 0.5 if ismpl else 0.7 fig._fake_click((0.5, yclick), ax=vscroll) @@ -531,7 +531,7 @@ def test_plot_raw_groupby(raw, browser_backend, group_by): fig._fake_click((0.5, 0.5), ax=fig.mne.ax_vscroll) # change channels if browser_backend.name == 'matplotlib': # Test lasso-selection - # (test difficult with pyqtgraph-backend, set plot_raw_selection) + # (test difficult with Qt-backend, set plot_raw_selection) sel_fig = fig.mne.fig_selection topo_ax = sel_fig.mne.sensor_ax fig._fake_click([-0.425, 0.20223853], fig=sel_fig, ax=topo_ax, @@ -662,7 +662,7 @@ def test_remove_annotations(raw, hide_which, browser_backend): def test_plot_raw_filtered(filtorder, raw, browser_backend): """Test filtering of raw plots.""" # Opening that many plots can cause a Segmentation fault - # if multithreading is activated in pyqtgraph-backend + # if multithreading is activated in Qt-backend pg_kwargs = {'precompute': False} with pytest.raises(ValueError, match='lowpass.*Nyquist'): raw.plot(lowpass=raw.info['sfreq'] / 2., filtorder=filtorder, diff --git a/mne/viz/utils.py b/mne/viz/utils.py index b19434b5d08..d425a700571 100644 --- a/mne/viz/utils.py +++ b/mne/viz/utils.py @@ -128,7 +128,7 @@ def _show_browser(show=True, block=True, fig=None, **kwargs): block : bool If to block execution on showing. fig : instance of Figure | None - Needs to be passed for pyqtgraph backend, + Needs to be passed for Qt backend, optional for matplotlib. **kwargs : dict Extra arguments for :func:`matplotlib.pyplot.show`.