-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Make join_segmentations return array maps from output to input labels #6786
Make join_segmentations return array maps from output to input labels #6786
Conversation
d6b8b01
to
fb09efe
Compare
|
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.
@aeisenbarth very cool!
In the long term for scikit-image, we are moving away from return_something=
arguments that change the return type, because they make typing very awkward. However, since we haven't quite decided yet what we'll replace it with 😅, I'm personally in favour of merging this. It's a very nice addition. I have left a couple of suggestions, but otherwise I'll approve once fixed. Thanks!!!
Shall I also add type hints? (I don't know whether scikit-image has any constraints on compatibility with older Python syntax). Something like this should correctly describe the optional return values: @overload
def join_segmentations(
s1: np.ndarray, s2: np.ndarray, return_mapping: Literal[False] = False
) -> np.ndarray:
...
@overload
def join_segmentations(
s1: np.ndarray, s2: np.ndarray, return_mapping: Literal[True]
) -> Tuple[np.ndarray, ArrayMap, ArrayMap]:
...
def join_segmentations(
s1: np.ndarray, s2: np.ndarray, return_mapping: bool = False
) -> Union[np.ndarray, Tuple[np.ndarray, ArrayMap, ArrayMap]]: |
Although, long-term type hints are the direction we want to go, right now they wouldn't be consistent with the rest of the library. So I'd say we don't need to add them in this PR. Thanks for introducing me to the |
Shall we merge this then? =) |
Happy to. Just didn't get around to review this yet... |
@lagru you're a busy man right now so I decided to save you some trouble 😂 |
…scikit-image#6786) Fixes scikit-image#6785. Adds as optional return value two ArrayMaps that allow tracing the labels of the returned segmentation back to the labels of the two input segmentations. * Make join_segmentations return array maps from output to input labels * Remove obsolete assertion * Rename variables * Reorder optional operation * Make example more comprehensible
…scikit-image#6786) Fixes scikit-image#6785. Adds as optional return value two ArrayMaps that allow tracing the labels of the returned segmentation back to the labels of the two input segmentations. * Make join_segmentations return array maps from output to input labels * Remove obsolete assertion * Rename variables * Reorder optional operation * Make example more comprehensible
Description
This is an implementation for #6785.
It adds as optional return value two ArrayMaps which allow tracing the labels of the returned segmentation back to the labels of the two input segmentations.
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.