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
Add new flag to convex_hull_image and grid_points_in_poly #6515
Conversation
Hello @dudulasry! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2022-09-12 22:10:13 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @dudulasry for your contribution ;)
When @grlee77 suggested adding a flag to the the grid_point_in_poly
, I read it as "Adding a flag to specify whether a vertices/edges are considered inside or outside the polygone"... Am I wrong @grlee77 ?
But providing a new function grid_point_in_poly_label
that returns the points labels would be a great addition 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @dudulasry! We are pretty close now 😉
I just disagree with the behavior introduced by the return_labels
argument in the convex_hull_image
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great! Thank you again @dudulasry 😉
Just a last little thing: the docstring still mentions return_labels
😅
Thanks for your fast code review. I updated the docstring one more time. Let me know if the PR is good now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just left a minor docstring fix, but the PR is approved from my side. Thank you @dudulasry 🎉
We now need a second @scikit-image/core approval for the changes to be included in next release.
BTW, is there a documentation anywhere regarding releasing new versions for this project? I'd like to know when are you guys planning on releasing a new version?
There is no such public documentation, but I am maybe mistaken here. @scikit-image/core may help us on this question 😉
Co-authored-by: Riadh Fezzani <rfezzani@gmail.com>
This looks basically good to go. @scikit-image/core any opinion on whether we should add a new function (here called |
Like I wrote in the comment, I don't know whether there are very many good options in cases like these. So far, our API decisions have leaned towards including it in the same function, as seen by a grep for |
@stefanv @rfezzani In that case, |
I am personally in favor of merging the functions into one, since they implement pretty much the same logic. As an alternative to the suggested earlier, the argument could be |
To throw one more idea out there: how do you feel about adding a parameter similar to In my opinion it can be a very explicit way to say "I want this optional thing stored here while being less problematic than modifying what is returned and easier to maintain than a separate function with duplicated documentation, tests, ... However, there is the disadvantage of requiring and validating a container as input to the parameter or a true callback. I'm curious how that idea seems to you in general. |
I took the habit to avoid using flags to control function's output type or count since reading previously cited @stefanv comment, as I consider it a reasonable convention. The deviation from the rule made in the past isn't a good justification to repeat this deviation. I 👍 |
I would prefer keeping only one function and adding a Thanks @dudulasry, your change is very nice insofar as it adds flexibility, letting the end-user binarize if/as they wish. |
@rfezzani That quote that you cite is not in defense of your argument. What I said there is: several people have told me they don't like the pattern, but the only alternative suggested feels even worse. There is some justification in repeating the pattern: consistency. The strongest argument I can see against the pattern is that it makes typing very difficult. |
The proposed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just found few bad imports 😉
@rfezzani Fixed :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @dudulasry 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dudulasry, apart from two tweaks to the docstrings I'm happy to approve this.
Co-authored-by: Lars Grüter <lagru+github@mailbox.org>
Co-authored-by: Lars Grüter <lagru+github@mailbox.org>
Co-authored-by: Lars Grüter <lagru+github@mailbox.org>
@lagru Hi, I applied your suggestions. Thanks for the feedback :) |
Merging. Thanks @dudulasry! 🎉 |
Description
Closes #6510
This PR addresses the problem described in #6510. The cause for this problem was also discussed in #3892, which was later addressed in this PR.
The solution that this PR offers is to add a flag to
convex_hull_image
,grid_points_in_poly
and_grid_points_in_poly
, offering to return the raw labels as well. This will allow the users of these functions to transform the raw labels array into a boolean array themselves.Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.example, to backport to v0.19.x after merging, add the following in a PR
comment:
@meeseeksdev backport to v0.19.x
run-benchmark
label. To rerun, the labelcan be removed and then added again. The benchmark output can be checked in
the "Actions" tab.