Restore original behavior of min_size in remove_small_* during its deprecation#8003
Conversation
to signal that a deprecated parameter received a value that was forwarded to the new parameter. This allows correcting for potentially changed behavior between deprecated and new parameter.
The deprecation accidentally changed the behavior of the deprecated `min_size`. However, the original behavior should stay available during the deprecation period! This fixes that. Furthermore, the new default must be `max_size=63` to be equivalent to the old `min_size=64`.
|
I submitted a PR against your feature branch that fixes some failing tests. I thought it would be easier that way than to add a code review comment explaining the changes! |
Fix deprecate_parameter tests for DEPRECATED_GOT_VALUE
min_size in remove_small_objects during its deprecationmin_size in remove_small_* during its deprecation
|
(And thank you @jmuhlich for the report and for contributing to this fix! 🙏) |
|
@lagru Want to update the description before merging? I like to have the final commit message describe the problem and fix more fully than just GH links. Example:
|
|
Done. I'll just merge right now. |
|
Feel welcome to edit the release note in the PR description further if you want. :) |
Yeah, I feel like that decorator is getting out of hand. If we had infinite time, I'd just refactor and split it for the different use cases. |
stefanv
left a comment
There was a problem hiding this comment.
Darnit; I reviewed this a while ago and forgot to press "submit" 🤦
| This is useful if ``None`` is already used for a different purpose or just | ||
| to highlight a deprecated parameter in the signature. | ||
|
|
||
| This is a sentinel and not meant to be initialized. |
There was a problem hiding this comment.
| This is a sentinel and not meant to be initialized. | |
| This is a sentinel and is not meant to be initialized. |
| """ | ||
|
|
||
|
|
||
| class DEPRECATED_GOT_VALUE(metaclass=PatchClassRepr): |
There was a problem hiding this comment.
Since this is internal, I'd opt for a descriptive name: DEPRECATED_BUT_RECEIVED_VALUE or DEPRECATED_BUT_SET_BY_USER.
There was a problem hiding this comment.
Actually, looking at the code below, another way to spell this would simply be RECEIVED_VALUE or SET_BY_USER, since it is used on the module: deprecate_parameter.SET_BY_USER or deprecate_paramer.RECEIVED_VALUE. (Would read better as deprecated_parameter.)
| ) | ||
| def remove_small_objects( | ||
| ar, min_size=DEPRECATED, connectivity=1, *, max_size=64, out=None | ||
| ar, min_size=DEPRECATED, connectivity=1, *, max_size=63, out=None |
|
No action needed on my late submission review; I'll make a PR for quick review, which you can choose to accept or not. |
Description
Fixes #8001
The renaming of
min_size/area_thresholdtomax_sizein #7739 was actually accompanied by a change in behaviour for the same value, due to using>in the old nomenclature and>=in the new one.Unfortunately our deprecation machinery was until now not smart enough to know whether a renamed parameter was provided under its old name or its new name. To address this, this PR:
min_size/area_thresholdby 1 to ensure that the new behaviour matches the old one.Checklist
./doc/examplesfor new featuresRelease note
For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.