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

Update existing inline examples to the new doctest style #1793

Merged
merged 1 commit into from
Mar 9, 2022

Conversation

seisman
Copy link
Member

@seisman seisman commented Mar 8, 2022

Description of proposed changes

Update inline examples to the new doctest style in #1790. Also fixes problems when running these doctests using pytest pygmt/src/*.py.

Address comment #1686 (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 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

@seisman seisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels Mar 8, 2022
@seisman seisman added this to the 0.6.0 milestone Mar 8, 2022
>>> new_grid = pygmt.grdgradient(
... grid=grid, azimuth=10, direction="c"
... ) # doctest: +SKIP
>>> new_grid = pygmt.grdgradient(grid=grid, azimuth=10)
Copy link
Member Author

Choose a reason for hiding this comment

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

The original example gives the following error:

grdgradient [ERROR]: Cannot specify both -A and -D

so I update this example.

But I'm using GMT dev branch.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I added that error following the discussion in GenericMappingTools/gmt#6327. It is good to update it.

@seisman
Copy link
Member Author

seisman commented Mar 8, 2022

When I run pytest pygmt/src/*.py, it seems all doctests run twice. I don't understand why.

@maxrjones
Copy link
Member

When I run pytest pygmt/src/*.py, it seems all doctests run twice. I don't understand why.

I think pytest collects each item once from pygmt/src/__init__.py and once from each other module.

@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Mar 8, 2022
@seisman seisman merged commit b5fa22b into main Mar 9, 2022
@seisman seisman deleted the new-doctest-style branch March 9, 2022 16:06
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants