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

Figure.contour: Adjust processing of arguments passed to the "annotation" and "levels" parameters #2706

Merged
merged 28 commits into from
Apr 28, 2024

Conversation

yvonnefroehlich
Copy link
Member

@yvonnefroehlich yvonnefroehlich commented Sep 30, 2023

Description of proposed changes

This PR aims to adjust the arguments passed to the annotation and levels parameters of Figure.contour:

  • input options
    - a fixed interval als float 100 -> 100
    - one level as list: [100] -> 100, (mention the trailing comma)
    - multiple levels as list: [100, 200] -> 100,200
    - no as string: "n" -> n (syntax of GMT 6.5)
  • Update docstrings
  • Add tests for interval, one level, and multiple levels

Related:

Preview: https://pygmt-dev--3116.org.readthedocs.build/en/2706/api/generated/pygmt.Figure.contour.html

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.
  • Use underscores (not hyphens) in names of Python files and directories.

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

@yvonnefroehlich yvonnefroehlich added documentation Improvements or additions to documentation skip-changelog Skip adding Pull Request to changelog labels Sep 30, 2023
@yvonnefroehlich yvonnefroehlich added this to the 0.11.0 milestone Sep 30, 2023
@seisman
Copy link
Member

seisman commented Oct 2, 2023

Both parameters are very complicated and the current docstrings are too simple.

@yvonnefroehlich
Copy link
Member Author

yvonnefroehlich commented Oct 2, 2023

Both parameters are very complicated and the current docstrings are too simple.

OK, I will try to find time to expand the docstrings for the annotation and the levels or interval parameters of Figure.contour and Figure.grdcontour following the upstream GMT documentation.

@seisman seisman marked this pull request as draft October 2, 2023 09:28
@yvonnefroehlich yvonnefroehlich changed the title Figure.contour, Figure.grdcontour: State all allowed input types for "annotation" and "levels" / "interval" Figure.contour, Figure.grdcontour: Expand docstrings for "annotation" and "levels" / "interval" Oct 2, 2023
@yvonnefroehlich yvonnefroehlich changed the title Figure.contour, Figure.grdcontour: Expand docstrings for "annotation" and "levels" / "interval" WIP: Figure.contour, Figure.grdcontour: Expand docstrings for "annotation" and "levels" / "interval" Oct 2, 2023
@yvonnefroehlich yvonnefroehlich self-assigned this Oct 2, 2023
@yvonnefroehlich
Copy link
Member Author

For me, the parameters levels and interval appear quite similar / identical. I am wondering whether there is a difference, which explains the different long parameter names.

This is actually related to issue #1042 by @maxrjones. I am wondering whether we should decide on one of these two aliases and deprecate the other one (in a separate PR).

@yvonnefroehlich yvonnefroehlich modified the milestones: 0.11.0, 0.12.0 Dec 15, 2023
@seisman seisman removed this from the 0.12.0 milestone Feb 26, 2024
@yvonnefroehlich yvonnefroehlich changed the title WIP: Figure.contour, Figure.grdcontour: Expand docstrings for "annotation" and "levels" / "interval" Figure.contour: Update documentation of "annotation" and "levels" Mar 20, 2024
@yvonnefroehlich yvonnefroehlich changed the title Figure.contour: Update docs of "annotation" and "levels" parameters Figure.contour: Adjust processing the agruments passed to the "annotation" and "levels" parameters Apr 26, 2024
@yvonnefroehlich yvonnefroehlich added the enhancement Improving an existing feature label Apr 26, 2024
@yvonnefroehlich
Copy link
Member Author

I am still not too happy with the aliases for C of Figure.grdcontour (interval) and of Figure.contour (levels):

So, maybe contours would be a better alias for C (see also https://docs.generic-mapping-tools.org/dev/grdcontour.html#c)?
Maybe we should complete the PRs #2706 and #3116 regarding the allowed input format, and then discuss this in more detail if these two deprecations are worth it?

@seisman
Copy link
Member

seisman commented Apr 26, 2024

I am still not too happy with the aliases for C of Figure.grdcontour (interval) and of Figure.contour (levels):

So, maybe contours would be a better alias for C (see also https://docs.generic-mapping-tools.org/dev/grdcontour.html#c)? Maybe we should complete the PRs #2706 and #3116 regarding the allowed input format, and then discuss this in more detail if these two deprecations are worth it?

I agree that these two wrappers should have the same parameter names, but I'm not sure if we should use contours. For reference, the matplotlib one also uses levels: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.contour.html

Copy link
Contributor

github-actions bot commented Apr 26, 2024

Summary of changed images

This is an auto-generated report of images that have changed on the DVC remote

Status Path
added pygmt/tests/baseline/test_contour_interval.png
added pygmt/tests/baseline/test_contour_multiple_levels.png
added pygmt/tests/baseline/test_contour_one_level.png

Image diff(s)

Added images

  • test_contour_interval.png

  • test_contour_multiple_levels.png

  • test_contour_one_level.png

Modified images

Path Old New

Report last updated at commit 6c24c49

@yvonnefroehlich
Copy link
Member Author

/format

@yvonnefroehlich yvonnefroehlich marked this pull request as ready for review April 26, 2024 15:36
@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Apr 27, 2024
@weiji14 weiji14 changed the title Figure.contour: Adjust processing the agruments passed to the "annotation" and "levels" parameters Figure.contour: Adjust processing of arguments passed to the "annotation" and "levels" parameters Apr 27, 2024
@yvonnefroehlich yvonnefroehlich mentioned this pull request Apr 27, 2024
9 tasks
@seisman
Copy link
Member

seisman commented Apr 28, 2024

/format

@seisman seisman removed deprecation Deprecating a feature final review call This PR requires final review and approval from a second reviewer labels Apr 28, 2024
@seisman seisman merged commit 38f91e1 into main Apr 28, 2024
18 of 20 checks passed
@seisman seisman deleted the fix-input-contour-AC branch April 28, 2024 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants