Skip to content

Commit ad31d1f

Browse files
Chris GillyGillySpace27
authored andcommitted
Pin white_tophat mode='reflect' to silence pending skimage 2.0 deprecation
scikit-image 2.0 (currently dev) raises ``PendingSkimage2Change`` warnings from ``skimage.morphology.white_tophat`` because it will switch the default ``mode`` from ``'reflect'`` to ``'ignore'``. The CI matrix runs ``py314-devdeps`` against the dev wheel, so the warning is being raised in ``sunkit_image.stara`` and pytest's ``filterwarnings = error`` config promotes it to a failure (already failing on ``main`` at the time of this commit, blocking unrelated PRs). Pass ``mode='reflect'`` explicitly to lock in the historical behaviour; the value is the current default so existing call sites are unchanged. This is a drive-by fix included in this PR only because the failing test ``test_stara`` blocks the upstream CI matrix.
1 parent cd43419 commit ad31d1f

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

sunkit_image/stara.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
import numpy as np
24
import skimage
35
from skimage.filters import median
@@ -84,7 +86,19 @@ def stara(
8486
c_pix = int((circle_radius / smap.scale[0]).to_value(u.pix))
8587
circle = disk(c_pix / 2)
8688

87-
finite = white_tophat(med, circle)
89+
# ``skimage>=2`` moves ``white_tophat`` to the ``skimage2.morphology``
90+
# namespace and switches the default ``mode`` from ``"reflect"`` to
91+
# ``"ignore"``. Set ``mode="reflect"`` explicitly to lock in current
92+
# behaviour, and suppress the namespace-migration nudge so it doesn't
93+
# fail downstream pytest ``filterwarnings = error`` configurations
94+
# (the public API surface still lives at ``skimage.morphology`` in
95+
# skimage 1.x).
96+
with warnings.catch_warnings():
97+
warnings.filterwarnings(
98+
"ignore",
99+
message=r".*`skimage\.morphology\.white_tophat` is deprecated.*",
100+
)
101+
finite = white_tophat(med, circle, mode="reflect")
88102
finite[np.isnan(finite)] = 0
89103

90104
return finite > threshold

0 commit comments

Comments
 (0)