GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Consistent (non-common) aliases between modules · Issue #1042 · GenericMappingTools/pygmt

Consistent (non-common) aliases between modules #1042

New issue
Copy link
New issue
Copy link
Closed
#3209
Closed
Consistent (non-common) aliases between modules#1042
#3209
Copy link
Labels
deprecationDeprecating a feature
Milestone
0.12.0

Description

@maxrjones
maxrjones
opened on Mar 12, 2021
Issue body actions

Description of the problem

The -C arguments (parameters) in contour and grdcontour do essentially the same thing. But, PyGMT uses different aliases for these parameters in the two methods (interval and level). I think it would be better to use the same aliases for options that are very similar across the various modules. This is harder to track for non-common options, so perhaps we can also create a tool for identifying similar GMT arguments across modules.

Activity

  1. maxrjones
    added
    enhancementImproving an existing feature
    on Mar 12, 2021
  2. willschlitzer commented on Mar 12, 2021

    @willschlitzer
    willschlitzer
    on Mar 12, 2021
    Contributor
    More actions

    I'm not familiar with the use of the -C in contour or grdcontour and don't want to cause any breaking changes before v0.3.1, but they have very different documentation. In the future I think we should standardize names, but for now, should we copy the interval documentation from grdcontour.py and copy it into levels in contour.py? I notice that interval states it can accept an integer or string, while levels just states that it can accept a string. I'm assuming that levels can accept an integer as well?

  3. maxrjones commented on Mar 12, 2021

    @maxrjones
    maxrjones
    on Mar 12, 2021
    MemberAuthor
    More actions

    I'm not familiar with the use of the -C in contour or grdcontour and don't want to cause any breaking changes before v0.3.1, but they have very different documentation. In the future I think we should standardize names, but for now, should we copy the interval documentation from grdcontour.py and copy it into levels in contour.py? I notice that interval states it can accept an integer or string, while levels just states that it can accept a string. I'm assuming that levels can accept an integer as well?

    Works for me:

    import pygmt
    import numpy as np
    
    np.random.seed(42)
    region = [0, 10, 0, 12]
    x = np.random.uniform(region[0], region[1], 100)
    y = np.random.uniform(region[2], region[3], 100)
    z = np.sqrt(x)*np.sqrt(y)
    
    fig = pygmt.Figure()
    fig.basemap(region=region, projection="X15c", frame=True)
    pygmt.makecpt(cmap="viridis", series=[z.min(),z.max()])
    fig.plot(x, y, style="c0.2c", cmap=True, color=z)
    fig.contour(x, y, z, levels=1,pen="thin")
    fig.show()
    
  4. willschlitzer commented on Mar 12, 2021

    @willschlitzer
    willschlitzer
    on Mar 12, 2021
    Contributor
    More actions

    Sounds good. I'll open a PR to copy the documentation.

  5. weiji14
    added
    help wantedHelping hands are appreciated
    on Nov 8, 2021
  6. seisman commented on Apr 28, 2024

    @seisman
    seisman
    on Apr 28, 2024
    Member
    More actions

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

    • As the behavior / functionality is similar (identical ?) the aliases should be identical. The Julia documentation
      says for both C or cont or contours or levels (https://www.generic-mapping-tools.org/GMTjl_doc/documentation/modules/grdcontour/index.html#grdcontour, https://www.generic-mapping-tools.org/GMTjl_doc/documentation/modules/contour/index.html#contour)
    • I fell is can be confusing to have an alias interval but pass specific levels, or an alias levels but pass an fixed interval.

    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

    Let's continue the discussions at #2706 (comment). It would be better if we can reach an agreement about the consistent parameter name and deprecate the old name in v0.12.0 and fully remove it in v0.16.0 considering that grdcontour/contour are commonly used. Ping @GenericMappingTools/pygmt-maintainers

    Reacted by Yvonne Fröhlich
  7. yvonnefroehlich commented on Apr 28, 2024

    @yvonnefroehlich
    yvonnefroehlich
    on Apr 28, 2024
    Member
    More actions

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

    • As the behavior / functionality is similar (identical ?) the aliases should be identical. The Julia documentation
      says for both C or cont or contours or levels (https://www.generic-mapping-tools.org/GMTjl_doc/documentation/modules/grdcontour/index.html#grdcontour, https://www.generic-mapping-tools.org/GMTjl_doc/documentation/modules/contour/index.html#contour)
    • I fell is can be confusing to have an alias interval but pass specific levels, or an alias levels but pass an fixed interval.

    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

    Let's continue the discussions at #2706 (comment). It would be better if we can reach an agreement about the consistent parameter name and deprecate the old name in v0.12.0 and fully remove it in v0.16.0 considering that grdcontour/contour are commonly used. Ping @GenericMappingTools/pygmt-maintainers

    Yes, I also thought about getting this in v0.12.0.
    I think the important point is to have the same alias for C of Figure.grdcontour and Figure.contour.
    levels is already used for Figure.contour, GMT Julia also supports this alias, and matplotlib uses levels. So, I think I am OK with this alias for C if the other @GenericMappingTools/pygmt-maintainers prefer it.

    Reacted by Dongdong Tian
  8. weiji14 commented on Apr 28, 2024

    @weiji14
    weiji14
    on Apr 28, 2024
    Member
    More actions

    Let's continue the discussions at #2706 (comment). It would be better if we can reach an agreement about the consistent parameter name and deprecate the old name in v0.12.0 and fully remove it in v0.16.0 considering that grdcontour/contour are commonly used. Ping @GenericMappingTools/pygmt-maintainers

    Yes, I also thought about getting this in v0.12.0. I think the important point is to have the same alias for C of Figure.grdcontour and Figure.contour. levels is already used for Figure.contour, GMT Julia also supports this alias, and matplotlib uses levels. So, I think I am OK with this alias for C if the other @GenericMappingTools/pygmt-maintainers prefer it.

    Yep, ok with using levels across both contour and grdcontour.

    Reacted by Dongdong Tian
  9. seisman commented on Apr 29, 2024

    @seisman
    seisman
    on Apr 29, 2024
    Member
    More actions

    @yvonnefroehlich Could you please open a PR to deprecate interval to levels in Figure.grdcontour?

  10. seisman
    added
    deprecationDeprecating a feature
    and removed
    help wantedHelping hands are appreciated
    enhancementImproving an existing feature
    on Apr 29, 2024
  11. seisman
    added this to the 0.12.0 milestone on Apr 29, 2024
  12. yvonnefroehlich commented on Apr 29, 2024

    @yvonnefroehlich
    yvonnefroehlich
    on Apr 29, 2024
    Member
    More actions

    @yvonnefroehlich Could you please open a PR to deprecate interval to levels in Figure.grdcontour?

    Submitted PR #3209 for this.

  13. seisman
    closed this as completedin #3209on Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    deprecationDeprecating a feature

    Type

    No type

    Projects

    No projects

      Milestone

      • 0.12.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.