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

Add inline code examples in data processing module docstrings #1686

Open
22 of 25 tasks
willschlitzer opened this issue Dec 24, 2021 · 13 comments
Open
22 of 25 tasks

Add inline code examples in data processing module docstrings #1686

willschlitzer opened this issue Dec 24, 2021 · 13 comments
Assignees
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Helping hands are appreciated longterm Long standing issues that need to be resolved

Comments

@willschlitzer
Copy link
Contributor

willschlitzer commented Dec 24, 2021

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

@willschlitzer willschlitzer added question Further information is requested feature request New feature wanted labels Dec 24, 2021
@willschlitzer willschlitzer self-assigned this Dec 24, 2021
@maxrjones
Copy link
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.

@willschlitzer willschlitzer changed the title Add inline code examples in module docstrings Add inline code examples in data processing module docstrings Jan 28, 2022
@willschlitzer
Copy link
Contributor Author

@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.

@maxrjones
Copy link
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.

@weiji14
Copy link
Member

weiji14 commented Jan 29, 2022

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.

@willschlitzer
Copy link
Contributor Author

willschlitzer commented May 5, 2022

Looking through the examples in the GMT documentation and PyGMT tests, a few of them call remote datasets without using a PyGMT function (e.g. @Table_5_11_mean.xyz for surface). Should the example just call the remote dataset as is (with the "@" in front calling the file), or should load_sample_data() be updated to include the remote datasets for the in-line example?

@maxrjones
Copy link
Member

Looking through the examples in the GMT documentation and PyGMT tests, a few of them call remote datasets without using a PyGMT function (e.g. @Table_5_11_mean.xyz for surface). Should the example just call the remote dataset as is (with the "@" in front calling the file), or should load_sample_data() be updated to include the remote datasets for the in-line example?

For tests, IMO it doesn't matter much. For user-facing examples I think it would be better to update load_sample_data.

@willschlitzer
Copy link
Contributor Author

willschlitzer commented May 6, 2022

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.

@maxrjones
Copy link
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

@willschlitzer
Copy link
Contributor Author

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!

@maxrjones
Copy link
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.

@seisman seisman modified the milestones: 0.7.0, 0.8.0 Jun 28, 2022
@seisman seisman unpinned this issue Dec 2, 2022
@seisman seisman modified the milestones: 0.8.0, 0.9.0 Dec 11, 2022
@seisman seisman modified the milestones: 0.9.0, 0.10.0 Mar 19, 2023
@weiji14 weiji14 added the longterm Long standing issues that need to be resolved label Aug 24, 2023
@weiji14 weiji14 removed this from the 0.10.0 milestone Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Helping hands are appreciated longterm Long standing issues that need to be resolved
Projects
None yet
Development

No branches or pull requests

4 participants