Skip to content

Add inline code examples in data processing module docstrings #1686

Open

Description

@willschlitzer

As first discussed in this comment, module docstrings should contain inline code examples to show a working example of the module with the correct syntax without needing to find an example page.

To prevent example functions from being run in tests, add _doctest_skip__ = [MODULE NAME] under the import statements.

Are you willing to help implement and maintain this feature? Yes

Activity

  1. maxrjones commented on Jan 20, 2022

    @maxrjones
    Member

    Regarding the CI issue raised in #1666 (comment), here are two options:

    1. Use the doctest skip directive to skip particular examples all the time.
    2. Add a new target to the Makefile to invoke pytest without doctest, such that the tests without docstring examples can be run on every PR and doctests could be run occasionally.
  2. changed the title [-]Add inline code examples in module docstrings[/-] [+]Add inline code examples in data processing module docstrings[/+] on Jan 28, 2022
  3. willschlitzer commented on Jan 28, 2022

    @willschlitzer
    ContributorAuthor

    @GenericMappingTools/pygmt-maintainers Should this only be for data processing modules that can't be as easily demonstrated as a plotting function, or should there be in-line examples for all of our modules?

    My vote is for all of them.

  4. maxrjones commented on Jan 28, 2022

    @maxrjones
    Member

    Should this only be for data processing modules that can't be as easily demonstrated as a plotting function, or should there be in-line examples for all of our modules?

    My vote is for all of them.

    Sounds good to me.

  5. weiji14 commented on Jan 29, 2022

    @weiji14
    Member

    Should this only be for data processing modules that can't be as easily demonstrated as a plotting function, or should there be in-line examples for all of our modules?

    My vote is for all of them.

    Sounds good to me.

    Ok with doing inline examples for all, but maybe prioritize those that don't already have a gallery example first. E.g. don't do grdgradient until much later.

  6. added
    help wantedHelping hands are appreciated
    documentationImprovements or additions to documentation
    and removed
    questionFurther information is requested
    on Feb 4, 2022
  7. added a commit that references this issue on Feb 13, 2022
  8. added this to the 0.6.0 milestone on Feb 16, 2022
  9. 10 remaining items

  10. willschlitzer commented on May 6, 2022

    @willschlitzer
    ContributorAuthor

    Are there any gridded datasets with holes in them to use for an example for grdfill? I can use the code from one of the tests, but it seems counterproductive to demo removing data from a grd file only to add it back in with grdfill.

  11. maxrjones commented on May 6, 2022

    @maxrjones
    Member

    Are there any gridded datasets with holes in them to use for an example for grdfill? I can use the code from one of the tests, but it seems counterproductive to demo removing data from a grd file only to add it back in with grdfill.

    Looking through https://oceania.generic-mapping-tools.org/cache/, data_w_nans.nc seems like one option. Below is a picture from the gmt tests that uses that file.

    image

  12. willschlitzer commented on May 6, 2022

    @willschlitzer
    ContributorAuthor

    Are there any gridded datasets with holes in them to use for an example for grdfill? I can use the code from one of the tests, but it seems counterproductive to demo removing data from a grd file only to add it back in with grdfill.

    Looking through https://oceania.generic-mapping-tools.org/cache/, data_w_nans.nc seems like one option. Below is a picture from the gmt tests that uses that file.

    image

    Thanks @meghanrjones!

  13. maxrjones commented on May 6, 2022

    @maxrjones
    Member

    Are there any gridded datasets with holes in them to use for an example for grdfill? I can use the code from one of the tests, but it seems counterproductive to demo removing data from a grd file only to add it back in with grdfill.

    There's now a better file to use - earth_relief_20m_holes.grd, see GenericMappingTools/gmt#6678 and GenericMappingTools/gmtserver-admin#155 for background.

  14. modified the milestones: 0.7.0, 0.8.0 on Jun 28, 2022
  15. unpinned this issue on Dec 2, 2022
  16. modified the milestones: 0.8.0, 0.9.0 on Dec 11, 2022
  17. modified the milestones: 0.9.0, 0.10.0 on Mar 19, 2023
  18. added
    longtermLong standing issues that need to be resolved
    on Aug 24, 2023
  19. removed this from the 0.10.0 milestone on Aug 24, 2023
  20. AisunZa commented on Nov 10, 2026

    @AisunZa
    Contributor

    Hi! I'd like to contribute a small documentation improvement for the unchecked filter1d item in this issue.

    My plan is to add a self-contained example demonstrating Gaussian filtering of a simple synthetic time series, limited to `pygmt/src/filter1d.py`.
    
    I'll follow the existing inline-example conventions and validate the example before submitting a PR.
    
    Thanks!
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationhelp wantedHelping hands are appreciatedlongtermLong standing issues that need to be resolved

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions