Skip to content

Clarify position of deprecate_parameter decorator to be above use_alias #1302

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

Merged
merged 1 commit into from
May 27, 2021

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented May 26, 2021

Description of proposed changes

Need to move the @deprecate_parameter decorator to be before @use_alias but after @fmt_docstring so that the @kwargs_to_strings decorator can do its job properly.

In code, it should look something like this.

@fmt_docstring
@deprecate_parameter("columns", "incols", "v0.4.0", remove_version="v0.6.0")
@use_alias(J="projection", R="region", V="verbose", i="incols")
@kwargs_to_strings(R="sequence", i='sequence_comma')
def plot(self, x=None, y=None, data=None, size=None, direction=None, **kwargs):
    pass

Explanation:

  1. Rename 'columns' to 'incols' via @deprecate_parameter
  2. Convert long alias 'incols' to GMT short alias 'i' via @use_alias
  3. Let the list type argument [0, 1] be converted to str type 0,1 via @kwargs_to_strings
  4. Pass in -i0,1 to lib.call_module("plot", ...)

Originally posted by @weiji14 in #1298 (comment)

Addresses #1298 (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

Need to move the `@deprecate_parameter` decorator to be
before `@use_alias` but after `@fmt_docstring` so that the
`@kwargs_to_strings` decorator can do its job properly.
@weiji14 weiji14 added the documentation Improvements or additions to documentation label May 26, 2021
@weiji14 weiji14 added this to the 0.4.0 milestone May 26, 2021
@weiji14 weiji14 self-assigned this May 26, 2021
@seisman
Copy link
Member

seisman commented May 26, 2021

The @deprecate_parameter decorator is already used in plot and plot3d. Do you want to fix the order of deprecate_parameter in these two functions?

@weiji14
Copy link
Member Author

weiji14 commented May 26, 2021

The @deprecate_parameter decorator is already used in plot and plot3d. Do you want to fix the order of deprecate_parameter in these two functions?

I'll let @michaelgrund fix the position of the decorator for plot in #1298, and @willschlitzer can fix it for plot3d in #1040.

@weiji14 weiji14 merged commit 5aefe73 into master May 27, 2021
@weiji14 weiji14 deleted the clarify-deprecation-decorator-position branch May 27, 2021 11:42
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
…as (GenericMappingTools#1302)

Need to move the `@deprecate_parameter` decorator to be
before `@use_alias` but after `@fmt_docstring` so that the
`@kwargs_to_strings` decorator can do its job properly.
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