Skip to content

Conversation

@cbrnr
Copy link
Contributor

@cbrnr cbrnr commented May 25, 2020

Fixes #7710 (change the default meg=True to meg=False in a deprecation cycle.

  • Fix/prepare examples/tutorials/etc.
  • Change also in pick_types_forward?
  • Any additional MEG bias we should remove in this PR?
  • Make arguments kw-only?

@cbrnr cbrnr marked this pull request as draft May 25, 2020 14:30
@cbrnr
Copy link
Contributor Author

cbrnr commented May 25, 2020

@larsoner can you check if the logic when to warn is OK like this?

@cbrnr
Copy link
Contributor Author

cbrnr commented May 25, 2020

Now do I catch all deprecation warnings individually or do I just disable this specific DeprecationWarning globally (do we have something like a pytest.ini config file?)?

@larsoner
Copy link
Member

You will probably need to update all tests that currently fail to now explicitly use meg=True to ensure they work the same way now and once we switch to meg=False as the default

@larsoner
Copy link
Member

Also you should push a commit with [circle full] in the message, it will show how many examples also break (we do not allow examples to give dep warnings) and thus also need to be updated

@larsoner
Copy link
Member

Sphinx-gallery successfully executed 97 out of 190 files subselected by:

Looks like that's 93 examples to change :(

@cbrnr
Copy link
Contributor Author

cbrnr commented May 26, 2020

Looks like that's 93 examples to change :(

Yep, I'm on it.

@larsoner
Copy link
Member

Change also in pick_types_forward?

Yes I think we should. I imagine this is used much more often internally than it is by users, so this won't inflict nearly as much pain for people than the primary pick_types deprecation will.

Any additional MEG bias we should remove in this PR?

pick_types and related functions are the only MEG-biased ones I can think of offhand

Make arguments kw-only?

pick_types has been around for 10 years now and I don't think we've ever tried to reorder the arguments, so I don't see too much point in doing so. There are probably people who have done pick_types(info, False, True) or `evoked.pick_types(False, True) knowing that meg/eeg are the first two non-info arguments, and I don't see a reason to break their code.

@cbrnr cbrnr marked this pull request as ready for review May 27, 2020 13:22
@cbrnr
Copy link
Contributor Author

cbrnr commented May 27, 2020

Except for my question about _pick_data_or_ica this is ready!

@cbrnr
Copy link
Contributor Author

cbrnr commented May 27, 2020

Last question solved, ready from my side!

@larsoner
Copy link
Member

needs rebase/merge, conflict


- The function ``mne.channels.read_dig_captrack`` will be deprecated in version 0.22 in favor of :func:`mne.channels.read_dig_captrak` to correct the spelling error: "captraCK" -> "captraK", by `Stefan Appelhoff`_

- The default argument ``meg=True`` in func:`mne.io.pick_types` will change to ``meg=False`` in version 0.22 by `Clemens Brunner`_
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 documented at the root level so this will be an error

https://mne.tools/stable/generated/mne.pick_types.html

Suggested change
- The default argument ``meg=True`` in func:`mne.io.pick_types` will change to ``meg=False`` in version 0.22 by `Clemens Brunner`_
- The default argument ``meg=True`` in func:`mne.pick_types` and related methods like :meth:`mne.io.Raw.pick_types` and :meth:`mne.Evoked.pick_types` will change to ``meg=False`` in version 0.22 by `Clemens Brunner`_

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just so I understand, where will this be an error (if the doc contains func:mne.io.pick_types)?

Copy link
Member

Choose a reason for hiding this comment

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

where will this be an error

CircleCI will say something about not being able to link to the ref properly, and the build will fail

Copy link
Member

Choose a reason for hiding this comment

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

(alternatively, locally you can do make html_dev-noplot in the doc/ directory then echo $? afterward it should not be zero, and if you look up you should see a warning about not being able to link properly)

Copy link
Member

Choose a reason for hiding this comment

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

... though I seem to remember your previous build being green, so maybe it figures out to go up to mne.pick_types when the mne.io.pick_types link is requested somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous CircleCI build was all green with exit code 0, yes.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like it was indeed green but shouldn't have been because the link did not get created correctly, maybe some latest Sphinx change made this fail to link without raising an error, not sure...

Copy link
Member

Choose a reason for hiding this comment

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

the linking failure is due to lack of a colon at the beginning of func

Copy link
Member

Choose a reason for hiding this comment

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

Grrr... thanks @drammock . I'll see if changing our default_role to something other than "autolink" linke "py:obj" would have made this error show up, in which case we should change it

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've inserted the missing colon and now use mne.pick_types.

Comment on lines +647 to +649
If True include MEG channels. If string it can be 'mag', 'grad',
'planar1' or 'planar2' to select only magnetometers, all
gradiometers, or a specific type of gradiometer.
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
If True include MEG channels. If string it can be 'mag', 'grad',
'planar1' or 'planar2' to select only magnetometers, all
gradiometers, or a specific type of gradiometer.
If ``True``, include MEG channels. If string, it can be ``'mag'``,
``'grad``', ``'planar1'`` or ``'planar2'`` to select only magnetometers
all gradiometers, or a specific type of gradiometer.

Copy link
Member

@hoechenberger hoechenberger left a comment

Choose a reason for hiding this comment

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

Just added a few suggestions

Comment on lines +661 to +664
If True include CTF / 4D reference channels. If 'auto', reference
channels are included if compensations are present and ``meg`` is
not False. Can also be the string options for the ``meg``
parameter.
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
If True include CTF / 4D reference channels. If 'auto', reference
channels are included if compensations are present and ``meg`` is
not False. Can also be the string options for the ``meg``
parameter.
If ``True``, include CTF / 4D reference channels. If ``'auto'``, reference
channels are included if compensations are present and ``meg`` is
not ``False``. Can also be the string options for the ``meg``
parameter.

Comment on lines +313 to +315
If True include MEG channels. If string it can be 'mag', 'grad',
'planar1' or 'planar2' to select only magnetometers, all gradiometers,
or a specific type of gradiometer.
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
If True include MEG channels. If string it can be 'mag', 'grad',
'planar1' or 'planar2' to select only magnetometers, all gradiometers,
or a specific type of gradiometer.
If ``True``, include MEG channels. If string, it can be ``'mag'``
``'grad'``, ``'planar1'`` or ``'planar2'`` to select only
magnetometers, all gradiometers, or a specific type of gradiometer.

Comment on lines +327 to +329
If True include CTF / 4D reference channels. If 'auto', reference
channels are included if compensations are present and ``meg`` is not
False. Can also be the string options for the ``meg`` parameter.
Copy link
Member

@hoechenberger hoechenberger May 27, 2020

Choose a reason for hiding this comment

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

Suggested change
If True include CTF / 4D reference channels. If 'auto', reference
channels are included if compensations are present and ``meg`` is not
False. Can also be the string options for the ``meg`` parameter.
If ``True``, include CTF / 4D reference channels. If ``'auto'``, reference
channels are included if compensations are present and ``meg`` is not
``False``. Can also be the string options for the ``meg`` parameter.

Comment on lines +667 to +669
If True include MEG channels. If string it can be 'mag', 'grad',
'planar1' or 'planar2' to select only magnetometers, all gradiometers,
or a specific type of gradiometer.
Copy link
Member

@hoechenberger hoechenberger May 27, 2020

Choose a reason for hiding this comment

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

Suggested change
If True include MEG channels. If string it can be 'mag', 'grad',
'planar1' or 'planar2' to select only magnetometers, all gradiometers,
or a specific type of gradiometer.
If ``True``, include MEG channels. If string, it can be ``'mag'``,
``'grad'``, ``'planar1'`` or ``'planar2'`` to select only
magnetometers, all gradiometers, or a specific type of gradiometer.

@cbrnr
Copy link
Contributor Author

cbrnr commented May 27, 2020

@hoechenberger do we really always have to double-backtick literals in docstrings? I know that this makes it show up as <code>, but IIRC we've had this discussion in the past and decided that it's not worth the effort (and additional characters).

@drammock
Copy link
Member

IIRC we've had this discussion in the past and decided that it's not worth the effort (and additional characters)

I don't understand the reasoning. We're not charged per-character, and the effort is about as minimal as it gets (press the key your finger is already on, twice instead of once). I'll concede that the changelog is probably the least important place to get this right (much more important in tutorials and docstrings), but remembering / enforcing to do it correctly here is a good way to reinforce the behavior so that it also happens everywhere else.

@hoechenberger
Copy link
Member

+100 @drammock

@cbrnr
Copy link
Contributor Author

cbrnr commented May 27, 2020

It's harder to read in plain text when I see everything surrounded by double backticks. But whatever, if we now do that I will change it.

@cbrnr
Copy link
Contributor Author

cbrnr commented May 27, 2020

meg : bool | str
    If ``True` include MEG channels. If string it can be ``'mag'``,
    ``'grad'``, ``'planar1'`` or ``'planar2'`` to select only
    magnetometers, all gradiometers, or a specific type of gradiometer.

You don't think this is harder to read (in plain text) (especially the literal strings)? Also, why change this only in a few selected parameter descriptions and not all? I don't want to do it here, if you think this is important please do it in a new PR.

@larsoner
Copy link
Member

You don't think this is harder to read (in plain text) (especially the literal strings)?

I find it a little bit harder, but not too much. And to me the RST rendering gain is worth the plain-text rendering loss. I'm fine with someone else working on this in another PR, though

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.

LGTM, the changeset is actually smaller than I expected!

@hoechenberger
Copy link
Member

hoechenberger commented May 27, 2020

You don't think this is harder to read (in plain text) (especially the literal strings)?

I think it's not easy to read without syntax highlighting that helps with this.

That being said, our users view the rendered output, and many IDEs provide rendered docstrings as well. So unless you're actually working on the docstrings, this shouldn't really affect you, no?

Also, why change this only in a few selected parameter descriptions and not all?

Because we're already inconsistent anyway and changing some bits "as we go" in PRs that change some lines of docstrings brings us a little closer to overall more consistently rendered docs.

I don't want to do it here

There's no need to, it was merely suggestions, no blockers from my end. Sorry if it came across otherwise!

@hoechenberger
Copy link
Member

hoechenberger commented May 28, 2020

FWIW, I'm using VS Code with the Highlight extension and the following setting:

    "highlight.regexes": {
        "(``)(.+?)(``)": [
            {"color": "#d88e73"},
            {"color": "#3c9ddb"},
            {"color": "#d88e73"}
        ]
    }

This produces:
Screenshot 2020-05-28 at 08 28 20

Maybe some of you may find this useful.

@cbrnr
Copy link
Contributor Author

cbrnr commented May 28, 2020

That's pretty neat! Is there anything similar for PyCharm?

@hoechenberger
Copy link
Member

That's pretty neat! Is there anything similar for PyCharm?

I'm afraid not, at least I haven't found anything so far :( There is a related support request from ~2 years ago:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000082599-Custom-syntax-highlighting

@cbrnr
Copy link
Contributor Author

cbrnr commented May 28, 2020

OK, that's a pity. Though it wouldn't really solve the issue, because users (as opposed to devs) will read docstrings mostly in their REPL (e.g. IPython), which means they will see just plain text without any fancy rST highlighting. I think enclosing every literal in double backticks is just overkill.

Also, it violates the numpydoc style recommendation that variables should be enclosed in single backticks: https://numpydoc.readthedocs.io/en/latest/format.html.

@hoechenberger
Copy link
Member

Thanks @cbrnr
@drammock, would there be a way to change the way we mark variable names and constants to make things more readable in plain text? Maybe we should open a new issue about this…

@drammock
Copy link
Member

users (as opposed to devs) will read docstrings mostly in their REPL (e.g. IPython)

@cbrnr Do we actually have evidence for this one way or the other? Anyone who uses Spyder will typically see HTML-rendered docs, for example.

would there be a way to change the way we mark variable names and constants to make things more readable in plain text?

@hoechenberger our sphinx config was recently changed so that anything surrounded by single ticks (which previously rendered as italics, redundant with single asterisks for yielding italics) will now always be treated as an attempted link or cross-reference by the build system. This allows Sphinx to catch errors like the recently seen

func:`some_function_name`

where func: was missing a leading colon. Previously it rendered as func:italicized_function_name and raised no error / warning. This change also means that the role prefix (:func:, :class: etc) can be omitted in most cases, which will allow us to simplify the plain-text docstrings considerably. It's a trade-off.

@cbrnr
Copy link
Contributor Author

cbrnr commented May 29, 2020

@cbrnr Do we actually have evidence for this one way or the other? Anyone who uses Spyder will typically see HTML-rendered docs, for example.

I only have anecdotal evidence from coworkers and students in my Python course, where the majority seems to be using plain-text docstrings (mostly via the IPython shortcut ?command or command?). Plain-text docs are always available no matter what editor or IDE you're using (even if HTML rendering is supported). Many editors don't support HTML rendering of docstrings out of the box (e.g. VS Code, PyCharm) - or at least I haven't figured out how to view HTML-rendered docs. It seems like Spyder is the only editor where this works out of the box.

👍 for the simplification! Regarding the use of double backticks, do we have docstring guidelines somewhere? If not I think it would be a good addition to have such a document in the contributing section.

@cbrnr
Copy link
Contributor Author

cbrnr commented May 29, 2020

@drammock @hoechenberger do you have any additional comments (let's do docstring formatting changes in another PR though)?

@hoechenberger
Copy link
Member

@cbrnr LGTM!

@hoechenberger
Copy link
Member

@drammock I think you can merge this if you're happy

@drammock
Copy link
Member

do we have docstring guidelines somewhere? If not I think it would be a good addition to have such a document in the contributing section.

added to #6266

@drammock drammock merged commit 002a5cf into mne-tools:master May 29, 2020
@drammock
Copy link
Member

thanks @cbrnr !

@cbrnr cbrnr deleted the pick-types branch May 29, 2020 14:25
larsoner added a commit to larsoner/mne-python that referenced this pull request Jun 5, 2020
* upstream/master:
  DOC: Order
  added reference
  FIX: Working
  working version
  ENH: More efficient
  actually working csd, needs review
  MAINT: Update dataset and add constant test (mne-tools#7866)
  DOC: update link to glasser supplementary info; convert to footbib (mne-tools#7864)
  FIX: Fix subtract_evoked with decim (mne-tools#7855)
  FIX: Fix reading of old TFRs (mne-tools#7851)
  DOC: Add evoked movecomp to example (mne-tools#7852)
  Deprecate meg=True in pick_types (mne-tools#7823)
  ENH: Allow reading broken file (mne-tools#7846)
  MRG, ENH: Add mixed source estimate support to compute_source_morph (mne-tools#7734)
  FIX: Fix bug with metadata and event_repeated (mne-tools#7733)
  MRG, ENH: Add axes to plot_evoked_white (mne-tools#7831)
  MRG, ENH: Add example of projection to source space (mne-tools#7705)
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.

Set all types to False in pick_types

4 participants