Repository navigation
Conform conversion of non-binary input in skeletonize functions - #7095
Conversation
|
It's not as uncontroversial as you think @lagru 😂 as I generally like the robustness principle ("be conservative in what you send, be liberal in what you accept"), and warnings are annoying, but I'm certainly happy to listen to the criticisms section there, so happy to go with this solution. I don't think we need to deprecate in 1.0, but maybe we can just remove it in skimage2? |
|
Theoretical rambling ahead I sympathize with the robustness principle from a short-term user perspective. But from a maintainer perspective and long-term user perspective, I don't think "be liberal in what you accept" is a good trade-off in a lot of cases. It makes the API surface larger which can be problematic for all kinds of reasons, not the least because it makes API changes more difficult. Documentation of parameters and behavior is generally more complex and the number of (unforseen) edge cases increases as well. That said, if I think about this issue again I mainly hate the inconsistency between behavior, and documentation. Either we accept non-binary arrays and document that or we don't. Users will start to rely on either behavior anyway. So I changed my opinion and don't think the warning is the proper way to deal with this. |
but add a minimal test for at least int and float dtype.
|
I propose accepting non-binary images for now as implied by the docstring of But I'll the "convert non-binary images implicitly" issue as an item to the list of API changes for skimage2 so that we can discuss it again and in context of the full library. |
That's great from my perspective, @lagru. It's amusing that shortly after I came here defending the robustness principle, it bit us in the ass in napari. That's karma for you! 😂 So I now 100% agree with strongly typing this in skimage2. But it's a good one to postpone/deprecate slowly rather than to just warn. |
Co-authored-by: Marianne Corvellec <[email protected]>
Co-authored-by: Marianne Corvellec <[email protected]>
Co-authored-by: Marianne Corvellec <[email protected]>
|
@lagru in the context of these functions, are thin/thinned and skeletonize/skeletonized strict synonyms? |
|
I was asking that myself. I am not sure. From Wikipedia on Topological skeleton
So, I suggest to use "thin" at least in |
Description
Our skeletonize API is currently dealing in multiple ways with non-binary input images. Sometimes it's just silently turned into a binary array and sometimes
img_as_ubyteis used (which scales).This PR adds a RuntimeWarning everywhere if the input image isn't binary, and conforms the conversion toimage.astype(bool, copy=False). This is probably the least controversial solution to #7090.This PR conforms the behavior. All functions convert non-binary input implicitly with
.astype(bool, copy=False).What do you think about deprecating the implicit conversion and raising a TypeError instead? That would make testing and maintenance a lot easier!
Closes #7090.
Checklist
./doc/examplesfor new featuresRelease note
Summarize the introduced changes in the code block below in one or a few sentences. The
summary will be included in the next release notes automatically: