Skip to content

[RFC] changing python type by a term definition in docstring #6698

Closed

Description

@massich

In the following docstring instead of using the python type as description, could we use a glossary term instead?

dig : list of dict | None
The Polhemus digitization data in head coordinates.
See Notes for more information.

Or maybe we should keep the python type and link the term in the description.

    dig : list of dict | None
        The Polhemus :term:`digitization` data in head coordinates.
        See Notes for more information.

WDYT?

cc: @drammock, @larsoner, @agramfort

Maybe something like this could work:

numpydoc_xref_aliases = {
    'Popen': 'python:subprocess.Popen',
    'file-like': ':term:`file-like <python:file object>`',
    ...
    # MNE
    'Label': 'mne.Label', 'Forward': 'mne.Forward', 'Evoked': 'mne.Evoked',
    ...
    'Transform': 'mne.transforms.Transform',
    # MNE-terms
    'digitization': ':term:`digitization`',
}

Suggested term

digitization (abbr. dig)
digpoint

Suggested definition

digitization: list of digpoints
digpoint: Dictionary contaning Polhemus digitization data (kind, identifier, position, and coord_frame)

@drammock feel free to rephrase the whole thing ;) (or push me to do it)

Activity

  1. agramfort commented on Aug 22, 2019

    @agramfort
    SponsorMember
  2. larsoner commented on Aug 22, 2019

    @larsoner
    Member

    Xref only looks in the param list so no value in adding it if we're going to use it in the description

  3. massich commented on Aug 22, 2019

    @massich
    ContributorAuthor

    @larsoner it was 2 different solutions to the same problem. Either one or the other but not both.

        dig : digitization | None
            The digitization object.
        dig : list of dict | None
            The ~Polhemus~ :term:`digitization` data in head coordinates.
            See Notes for more information.

    I like the first one better.

  4. massich commented on Aug 22, 2019

    @massich
    ContributorAuthor

    if its a digitization I've the right to just error say wrong type whatever.

  5. larsoner commented on Aug 22, 2019

    @larsoner
    Member

    I would leave it as instance of Digitization in the type, what's wrong with doing it that way? Changing it to list of dict also has disadvantages, we need to explain what the dicts are. And we don't really want people thinking they can pass a list of dict and have it work. So I'm -1 on this, rather keep it as instance of Digitization.

    You can keep the :term: in the description, though, if it helps

  6. agramfort commented on Aug 22, 2019

    @agramfort
    SponsorMember
  7. larsoner commented on Aug 22, 2019

    @larsoner
    Member

    The advantage of having it in the public API is that people don't think "I can just pass a list of dict" and I see little disadvantage to keeping it. What's the advantage to removing it?

  8. agramfort commented on Aug 22, 2019

    @agramfort
    SponsorMember
  9. drammock commented on Aug 22, 2019

    @drammock
    Member

    Regarding the new glossary entry: don't include the (abbr. dig) part in the head word line, it makes the crossrefs annoying to type. put it in the definition.

  10. larsoner commented on Aug 22, 2019

    @larsoner
    Member

    Okay I can live with removing the class. It will hopefully also fix the spurious failures in Travis that occur due to our changing how __eq__ works. We'll probably want a little assert_dig_equal in tests instead

  11. massich commented on Aug 22, 2019

    @massich
    ContributorAuthor
  12. massich commented on Aug 22, 2019

    @massich
    ContributorAuthor
  13. larsoner commented on Aug 22, 2019

    @larsoner
    Member

    That is the way we do it now and it seems to cause spurious failures where Pytest tries to do some introspection and fails. Hence why I'm saying we should switch to something else.

    Maybe just object_diff since it will give us the diff on failure of assert object_diff(x, y) == '' too.

  14. massich commented on Aug 22, 2019

    @massich
    ContributorAuthor
  15. larsoner commented on Aug 22, 2019

    @larsoner
    Member

    Now that we are getting rid of / making private Digitization it makes sense to keep it as close to list of dict as possible, rather than going in the opposite direction by making it a non-list class

  16. larsoner commented on Sep 21, 2019

    @larsoner
    Member

    Closing for #6434

  17. larsoner commented on Sep 21, 2019

    @larsoner
    Member

    Whoops I mean #6461

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions