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

Standardize docstrings for table-like inputs #1186

Merged
merged 19 commits into from
May 16, 2021

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented Apr 6, 2021

Description of proposed changes

The virtualfile_from_data function wrapped in #961 allows for a standardized way for inputting data to PyGMT modules. This change is for standardizing some of the docstrings, specifically for modules that accept 'table-like' vector inputs. The inputs can be of several different PyData object types.

Plus there will likely be more data type objects wrapped in the future, so it will be good to have a standardized place for them.

TODO:

Addresses #1000 (comment)

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

weiji14 added 5 commits April 6, 2021 14:31
The virtualfile_from_data function wrapped in #961
allows for a standardized way for inputting data to
PyGMT modules. This change is for standardizing
some of the docstrings, specifically for 'table-like'
vector inputs which can be of several different
PyData object types.
@weiji14 weiji14 added the documentation Improvements or additions to documentation label Apr 6, 2021
@weiji14 weiji14 added this to the 0.4.0 milestone Apr 6, 2021
@weiji14 weiji14 self-assigned this Apr 6, 2021
@weiji14 weiji14 marked this pull request as ready for review May 9, 2021 22:06
@weiji14 weiji14 requested a review from a team May 9, 2021 22:06
Copy link
Member

@maxrjones maxrjones left a comment

Choose a reason for hiding this comment

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

Would it be worth standardizing the description that accompanies {table-like} in each parameter? e.i., "a 1D/2D :class:numpy.ndarray, a :class:pandas.DataFrame, or an :class:xarray.Dataset made up of 1D :class:xarray.DataArray data variables containing the tabular data."

@weiji14
Copy link
Member Author

weiji14 commented May 10, 2021

Would it be worth standardizing the description that accompanies {table-like} in each parameter? e.i., "a 1D/2D :class:numpy.ndarray, a :class:pandas.DataFrame, or an :class:xarray.Dataset made up of 1D :class:xarray.DataArray data variables containing the tabular data."

Yes I did think of adding a standard {table-description}. The problem is that someone running help() on the function in Python would only see the curly brackets and not the expanded description (see image below as an example). The 'Full option list at GMT website' line doesn't get expanded into the full URL in the help docs, it is available only on the online PyGMT docs page.

image

@maxrjones
Copy link
Member

maxrjones commented May 13, 2021

Would it be worth standardizing the description that accompanies {table-like} in each parameter? e.i., "a 1D/2D :class:numpy.ndarray, a :class:pandas.DataFrame, or an :class:xarray.Dataset made up of 1D :class:xarray.DataArray data variables containing the tabular data."

Yes I did think of adding a standard {table-description}. The problem is that someone running help() on the function in Python would only see the curly brackets and not the expanded description (see image below as an example). The 'Full option list at GMT website' line doesn't get expanded into the full URL in the help docs, it is available only on the online PyGMT docs page.

If there were a filler_text["table-description"] similar to filler_text["table-list"], I think it would still be printed by help() in contrast to the sphinx-dependent documentation (e.g., :gmt-docs and **bold**). But, it would not be as simple as filler_text["aliases"] or filler_text["table-list"] to format the docstring with a standard {table-description}. So, I am OK with moving forward without that standard replacement text.

Would you prefer to wait on the last three methods or get a final review on this now to merge? It will be at least a few days before I get to the blockm* refactoring.

@weiji14
Copy link
Member Author

weiji14 commented May 14, 2021

If there were a filler_text["table-description"] similar to filler_text["table-list"], I think it would still be printed by help() in contrast to the sphinx-dependent documentation (e.g., :gmt-docs and **bold**). But, it would not be as simple as filler_text["aliases"] or filler_text["table-list"] to format the docstring with a standard {table-description}. So, I am OK with moving forward without that standard replacement text.

Hmm, you're right. I'll update things to use a standard {table-description}, will take me an hour or so after lunch. Edit: done in 44f941b.

Would you prefer to wait on the last three methods or get a final review on this now to merge? It will be at least a few days before I get to the blockm* refactoring.

I think we can do the last three methods next time. Prefer to get this PR in so that I can finalize the geopandas integration PR at #1000. But I'll do the {table-description} issue above ☝️ first.

@maxrjones maxrjones self-requested a review May 14, 2021 17:25
Also had to remove curly brackets from doctest so that they are not treated as placeholders to be substituted.
@weiji14 weiji14 merged commit ddec7c8 into master May 16, 2021
@weiji14 weiji14 deleted the standardize-table-like-docs branch May 16, 2021 23:21
@maxrjones maxrjones mentioned this pull request May 23, 2021
5 tasks
@weiji14 weiji14 mentioned this pull request Sep 15, 2021
5 tasks
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
The virtualfile_from_data function wrapped in GenericMappingTools#961
allows for a standardized way for inputting data to
PyGMT modules. This change is for standardizing
some of the docstrings, specifically for 'table-like'
vector inputs which can be of several different
PyData object types.

* Reformat pygmt.info docstring to use table-like filler
* Reformat plot and plot3d docstring to use table-like filler
* Reformat data_kind and virtualfile_from_data docstring to use table-like filler
* Reformat rose docstring to use table-like filler
* Reformat grdtrack docstring to use table-like filler
* Reformat velo docstring to use table-like filler
* Reformat wiggle docstring to use table-like filler
* Reformat histogram docstring to use table-like filler
* Add Python list to histogram's table param description
* Use table-classes filler in docstring description
* Use fmt_docstring decorator on virtualfile_from_data function

Also had to remove curly brackets from doctest so that
they are not treated as placeholders to be substituted.

* Add a doctest for the table-classes filler text

Co-authored-by: Meghan Jones <[email protected]>
Co-authored-by: Dongdong Tian <[email protected]>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants