Skip to content

Update existing inline examples to the new doctest style - #1793

Merged
seisman merged 1 commit into
mainfrom
new-doctest-style
Mar 9, 2022
Merged

Update existing inline examples to the new doctest style#1793
seisman merged 1 commit into
mainfrom
new-doctest-style

Conversation

@seisman

Copy link
Copy Markdown
Member

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

@seismanseisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels Mar 8, 2022
@seismanseisman 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
Copy Markdown
MemberAuthor

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
Copy Markdown
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
Copy Markdown
MemberAuthor

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

@maxrjones

Copy link
Copy Markdown
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.

@seismanseisman 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 mainMar 9, 2022
@seisman
seisman deleted the new-doctest-style branch March 9, 2022 16:06
@seismanseisman removed the final review call This PR requires final review and approval from a second reviewer label Mar 9, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenanceBoring but important stuff for the core devsskip-changelogSkip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@seisman@maxrjones