Description:
With the deprecation of the min_size argument to remove_small_objects in 0.26, the behavior when passing min_size is now different than before. My expectation is that deprecation preserves the existing behavior (until the functionality is removed completely of course).
The arg deprecation is handled by deprecate_parameter, but this helper seems to be intended just for parameter renaming, not changes in the interpretation of the value. It forcibly overwrites the "old" arg name with DEPRECATED, preventing the backwards-compatibility logic in remove_small_objects from being able to tell when the old name is used. min_size is always DEPRECATED at this point so this check is never true:
|
if min_size is not DEPRECATED: |
|
# Exclusive threshold is deprecated behavior |
|
too_small = component_sizes < min_size |
I guess deprecate_parameter needs a way to prevent overwriting the old arg name if the function itself wants to handle things.
Way to reproduce:
import numpy as np
from skimage.morphology import remove_small_objects
img = np.array([[1, 2, 2]])
# Remove all objects strictly smaller than size 2
res = remove_small_objects(img, 2)
print(res)
# 0.25: [[0 2 2]] (correct)
# 0.26: [[0 0 0]] (wrong, this is the result of max_size=2)
Version information:
3.12.3 (main, Nov 6 2025, 13:44:16) [GCC 13.3.0]
Linux-6.8.0-64-generic-x86_64-with-glibc2.39
scikit-image version: 0.26.0
numpy version: 2.4.0
Description:
With the deprecation of the
min_sizeargument toremove_small_objectsin 0.26, the behavior when passingmin_sizeis now different than before. My expectation is that deprecation preserves the existing behavior (until the functionality is removed completely of course).The arg deprecation is handled by
deprecate_parameter, but this helper seems to be intended just for parameter renaming, not changes in the interpretation of the value. It forcibly overwrites the "old" arg name withDEPRECATED, preventing the backwards-compatibility logic inremove_small_objectsfrom being able to tell when the old name is used.min_sizeis alwaysDEPRECATEDat this point so this check is never true:scikit-image/src/skimage/morphology/misc.py
Lines 170 to 172 in e02336e
I guess
deprecate_parameterneeds a way to prevent overwriting the old arg name if the function itself wants to handle things.Way to reproduce:
Version information: