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 example for grdvolume #1726

Merged
merged 15 commits into from
Mar 16, 2022
Merged

Add inline example for grdvolume #1726

merged 15 commits into from
Mar 16, 2022

Conversation

willschlitzer
Copy link
Contributor

This PR adds an inline code example to the docstring for grdvolume.

Addresses #1686

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 wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • 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

@willschlitzer willschlitzer added the documentation Improvements or additions to documentation label Feb 5, 2022
@willschlitzer willschlitzer added this to the 0.6.0 milestone Feb 5, 2022
@willschlitzer willschlitzer self-assigned this Feb 5, 2022
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
pygmt/src/grdvolume.py Outdated Show resolved Hide resolved
Copy link
Member

@seisman seisman left a comment

Choose a reason for hiding this comment

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

Looks good to me except a typo.

@seisman
Copy link
Member

seisman commented Mar 7, 2022

Need to fix the styling issue before merge.

@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed final review call This PR requires final review and approval from a second reviewer labels Mar 7, 2022
pygmt/src/grdvolume.py Outdated Show resolved Hide resolved
pygmt/src/grdvolume.py Outdated Show resolved Hide resolved
pygmt/src/grdvolume.py Outdated Show resolved Hide resolved
@weiji14 weiji14 modified the milestones: 0.6.0, 0.6.1 Mar 11, 2022
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Mar 11, 2022
pygmt/src/grdvolume.py Outdated Show resolved Hide resolved
@weiji14 weiji14 modified the milestones: 0.6.1, 0.6.0 Mar 11, 2022
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
pygmt/src/grdvolume.py Outdated Show resolved Hide resolved
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
pygmt/src/grdvolume.py Outdated Show resolved Hide resolved
>>> # maximum to 400, and the interval to 50.
>>> output_array = pygmt.grdvolume(
... grid=grid, contour=[200, 400, 50], output_type="numpy"
... )
"""
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, we would have nice column names like in grdhisteq:

>>> bins = pygmt.grdhisteq.compute_bins(grid=grid, divisions=5)
>>> print(bins)
start stop
bin_id
0 179.0 397.5
1 397.5 475.5
2 475.5 573.5
3 573.5 710.5
4 710.5 2103.0

But for the sake of time, and just finish this inline example, let's go with this:

Suggested change
"""
>>> print(output_dataframe)
0 1 2 3
0 200 2.144285e+12 7.972228e+14 371.789489
1 250 2.104042e+12 6.908183e+14 328.329232
2 300 2.014978e+12 5.877195e+14 291.675420
3 350 1.892109e+12 4.897545e+14 258.840510
4 400 1.744792e+12 3.988316e+14 228.584026
"""

Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
willschlitzer and others added 2 commits March 14, 2022 10:45
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
@seisman seisman modified the milestones: 0.6.0, 0.6.1 Mar 14, 2022
@willschlitzer willschlitzer removed the final review call This PR requires final review and approval from a second reviewer label Mar 16, 2022
@willschlitzer willschlitzer merged commit 1b6b040 into main Mar 16, 2022
@willschlitzer willschlitzer deleted the inline-example/grdvolume branch March 16, 2022 10:26
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
* Add an inline example to grdvolume.py

Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
This pull request was closed.
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.

5 participants