You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
Reacted by François Boulogne and Marianne Corvellec
(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!)
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 ;-)
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.
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.
One issue with neighborhood/neighbourhood is potential confusion due to differing american/british spellings. For that reason, I like footprint a bit better.
Reacted by Emmanuelle Gouillart and François Boulogne
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.
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.
Activity
sciunto commentedon Sep 12, 2019
This is correct. See also #2613 #2604 for other issues related to uniformity.
hmaarrfk commentedon Sep 12, 2019
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.
sciunto commentedon Sep 12, 2019
@hmaarrfk #2616
jni commentedon Sep 13, 2019
A big 👍 on unifying these argument names, thanks for raising this issue @rfezzani! My preference would be
max_num_iterwhen it is an upper-bound, andnum_iterwhen it is exact.jni commentedon Sep 13, 2019
(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!)
rfezzani commentedon Sep 13, 2019
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_iterandnum_iter;-)rfezzani commentedon Dec 10, 2019
For ref.
rfezzani commentedon Dec 10, 2019
Concerning the
selemargument name inconsistency identified in #4209, I found:seleminskimage.filters.rankmodule's functions,seleminskimage.morphologymodule's functions,structureinskimage.morphology._util._offsets_to_raveled_neighbors,footprintinskimage.feature.peak.peak_local_maxandskimage.feature.peak._get_peak_maskjni commentedon Dec 11, 2019
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.
anntzer commentedon Dec 11, 2019
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...
rfezzani commentedon Dec 11, 2019
Thank you @anntzer, I didn't knew this one! I already proposed #4158 a decorator in the same spirit ;-)
rfezzani commentedon Dec 11, 2019
You may also be interested in @hmaarrfk wabisabi package.
emmanuelle commentedon Apr 15, 2020
My two cents regarding selem / structure / footprint (/ neighbourhood as proposed by @jni / kernel or element as used in opencv).
selemis what we use the most throughoutmorphologyin particular. Nevertheless "structuring element" is mathematical morphology jargon, therefore it is quite obscure for most users. I likefootprintthe most I think, then neighbourhood and kernel. Having a simple word which is easy to understand is important I think.grlee77 commentedon Apr 15, 2020
One issue with neighborhood/neighbourhood is potential confusion due to differing american/british spellings. For that reason, I like
footprinta bit better.emmanuelle commentedon Apr 15, 2020
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.
JDWarner commentedon Apr 15, 2020
I'm on board with
footprint(patchactually seems pretty good to me as well). I agree with @jni thatselemis 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 termselemin the docs. Especially inskimage.morphology.rfezzani commentedon Apr 27, 2021
Cross-ref #5359
grlee77 commentedon Jun 26, 2021
To summarize the above, it looks like the current consensus is:
Myself, @emmanuelle and @JDWarner seem on board with
footprintin theselem/structure/footprintcase (also @lagru and @sciunto via emoji)For iterations, @jni and @rfezzani expressed a preference for
num_iterandmax_num_iter(also @sciunto and @mkcor via emoji)grlee77 commentedon Nov 5, 2021
Both the
footprintandnum_itercases have been addressed for 0.19, so this issue was resolved (I deleted the discussion topic that had been created)