Skip to content

Define standard common argument's names #4154

Closed

Description

@rfezzani

Description

It is important for a library to be consistent in arguments naming. The issue #4003 points out such problem.
I noticed for example that the argument for the "maximum number of iterations" has at least 5 names over skimage functions:

  • max_iter in slic,
  • max_iterations in active_contour,
  • iterations in richardson_lucy,
  • n_iter_max in denoise_tv_chambolle,
  • niter in optical_flow_tvl1.

What about defining standards for such common argument names and fixing the code base in the same spirit as #4152?

Activity

  1. added this to the 1.0 milestone on Sep 12, 2019
  2. sciunto commented on Sep 12, 2019

    @sciunto
    Member

    This is correct. See also #2613 #2604 for other issues related to uniformity.

  3. hmaarrfk commented on Sep 12, 2019

    @hmaarrfk
    Member

    Seems like a documentation challenge.

    Want to cross post your gist?

    This stuff here can also help:

    https://github.com/hmaarrfk/wabisabi

    It also write the warning in the documentation for you.

  4. sciunto commented on Sep 12, 2019

    @sciunto
    Member
  5. jni commented on Sep 13, 2019

    @jni
    Member

    A big 👍 on unifying these argument names, thanks for raising this issue @rfezzani! My preference would be max_num_iter when it is an upper-bound, and num_iter when it is exact.

  6. jni commented on Sep 13, 2019

    @jni
    Member

    (imho unified argument names is a requirement to release scikit-image 1.0. I intend to do a full review of the API for this purpose in the next few months. But thanks again to @rfezzani for starting the process!)

  7. rfezzani commented on Sep 13, 2019

    @rfezzani
    MemberAuthor

    I didn't knew wabisabi, thank you @hmaarrfk for pointing it. You also are right, the decorator defined in this gist can be used for this issue. The PR #4158 is an example of function's signature modification using such a decorator. I managed the documentation by hand, without specifying the warning. I don't know if it is necessary since the documentation is updated using the new name and the warning is supposed to be temporary...
    @jni, I also vote for max_num_iter and num_iter ;-)

  8. rfezzani commented on Dec 10, 2019

    @rfezzani
    MemberAuthor

    For ref.

  9. rfezzani commented on Dec 10, 2019

    @rfezzani
    MemberAuthor

    Concerning the selem argument name inconsistency identified in #4209, I found:

    • selem in skimage.filters.rank module's functions,
    • selem in skimage.morphology module's functions,
    • structure in skimage.morphology._util._offsets_to_raveled_neighbors,
    • footprint in skimage.feature.peak.peak_local_max and skimage.feature.peak._get_peak_mask
  10. jni commented on Dec 11, 2019

    @jni
    Member

    Thanks for the investigation!

    Since we have all those uses, I think it makes sense to find the one we like most and use it, since something will have to be deprecated whatever we choose. (Even though of course some deprecations are more panful than others.) Again, imho selem is really the worst of them.

  11. anntzer commented on Dec 11, 2019

    @anntzer
    Contributor

    fwiw you may be interested in using https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/cbook/deprecation.py#L258 (a renaming decorator that handles the deprecation @rename_parameter(version_number, old_name, new_name)) rather than manually going through all of them.
    It uses some other matplotlib internal deprecation machinery but should be easy enough to adapt for skimage...

  12. rfezzani commented on Dec 11, 2019

    @rfezzani
    MemberAuthor

    Thank you @anntzer, I didn't knew this one! I already proposed #4158 a decorator in the same spirit ;-)

  13. rfezzani commented on Dec 11, 2019

    @rfezzani
    MemberAuthor

    You may also be interested in @hmaarrfk wabisabi package.

  14. emmanuelle commented on Apr 15, 2020

    @emmanuelle
    Member

    My two cents regarding selem / structure / footprint (/ neighbourhood as proposed by @jni / kernel or element as used in opencv). selem is what we use the most throughout morphology in particular. Nevertheless "structuring element" is mathematical morphology jargon, therefore it is quite obscure for most users. I like footprint the most I think, then neighbourhood and kernel. Having a simple word which is easy to understand is important I think.

  15. grlee77 commented on Apr 15, 2020

    @grlee77
    Contributor

    One issue with neighborhood/neighbourhood is potential confusion due to differing american/british spellings. For that reason, I like footprint a bit better.

  16. emmanuelle commented on Apr 15, 2020

    @emmanuelle
    Member

    Another point is that we should try to reduce the number of possible keyword arguments throughout the library in order to decrease the cognitive load. For example, all arguments which are a small patch/neighbourhood/kernel etc. could have the same name. The actual name whether its kernel, footprint, structure or neighbourhood is not that important -- except for the fact that if we can be consistent with another major library, it's a bonus.

  17. JDWarner commented on Apr 15, 2020

    @JDWarner
    Contributor

    I'm on board with footprint (patch actually seems pretty good to me as well). I agree with @jni that selem is probably the worst of the bunch for a new user. Paradoxically it's also what anyone coming from Matlab would expect and look for first (probably why it got used early on), and pretty well understood/assumed in mathematical morphology circles.

    If we change away from selem, all places where it was previously should probably continue to mention the term selem in the docs. Especially in skimage.morphology.

  18. added
    📜 type: API
    on Jan 25, 2021
  19. rfezzani commented on Apr 27, 2021

    @rfezzani
    MemberAuthor

    Cross-ref #5359

  20. grlee77 commented on Jun 26, 2021

    @grlee77
    Contributor

    To summarize the above, it looks like the current consensus is:

    Myself, @emmanuelle and @JDWarner seem on board with footprint in the selem/structure/footprint case (also @lagru and @sciunto via emoji)

    For iterations, @jni and @rfezzani expressed a preference for num_iter and max_num_iter (also @sciunto and @mkcor via emoji)

  21. locked and limited conversation to collaborators on Oct 18, 2021
  22. grlee77 commented on Nov 5, 2021

    @grlee77
    Contributor

    Both the footprint and num_iter cases have been addressed for 0.19, so this issue was resolved (I deleted the discussion topic that had been created)

  23. modified the milestones: 0.21, 0.20 on Jan 19, 2023
  24. moved this to Done in skimage2on Aug 5, 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

    📜 type: API

    Projects

    • Status
      Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions