8000 MAINT Remove Cython compilation warnings ahead of Cython3.0 release (… · jeremiedbb/scikit-learn@dfe9e2e · GitHub
[go: up one dir, main page]

Skip to content

Commit dfe9e2e

Browse files
authored
MAINT Remove Cython compilation warnings ahead of Cython3.0 release (scikit-learn#25621)
1 parent dd18df5 commit dfe9e2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+598
-614
lines changed

sklearn/_build_utils/__init__.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def cythonize_extensions(extension):
4040
"""Check that a recent Cython is available and cythonize extensions"""
4141
_check_cython_version()
4242
from Cython.Build import cythonize
43-
import Cython
4443

4544
# Fast fail before cythonization if compiler fails compiling basic test
4645
# code even without OpenMP
@@ -80,21 +79,6 @@ def cythonize_extensions(extension):
8079
"cdivision": True,
8180
}
8281

83-
# TODO: once Cython 3 is released and we require Cython>=3 we should get
84-
# rid of the `legacy_implicit_noexcept` directive.
85-
# This should mostly consist in:
86-
#
87-
# - ensuring nogil is at the end of function signature,
88-
# e.g. replace "nogil except -1" by "except -1 nogil".
89-
#
90-
# - "noexcept"-qualifying Cython and externalized C interfaces
91-
# which aren't raising nor propagating exceptions.
92-
# See: https://cython.readthedocs.io/en/latest/src/userguide/language_basics.html#error-return-values # noqa
93-
#
94-
# See: https://github.com/cython/cython/issues/5088 for more details
95-
if parse(Cython.__version__) > parse("3.0.0a11"):
96-
compiler_directives["legacy_implicit_noexcept"] = True
97-
9882
return cythonize(
9983
extension,
10084
nthreads=n_jobs,

sklearn/_loss/_loss.pxd

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,57 +20,57 @@ ctypedef struct double_pair:
2020

2121
# C base class for loss functions
2222
cdef class CyLossFunction:
23-
cdef double cy_loss(self, double y_true, double raw_prediction) nogil
24-
cdef double cy_gradient(self, double y_true, double raw_prediction) nogil
25-
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) nogil
23+
cdef double cy_loss(self, double y_true, double raw_prediction) noexcept nogil
24+
cdef double cy_gradient(self, double y_true, double raw_prediction) noexcept nogil
25+
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) noexcept nogil
2626

2727

2828
cdef class CyHalfSquaredError(CyLossFunction):
29-
cdef double cy_loss(self, double y_true, double raw_prediction) nogil
30-
cdef double cy_gradient(self, double y_true, double raw_prediction) nogil
31-
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) nogil
29+
cdef double cy_loss(self, double y_true, double raw_prediction) noexcept nogil
30+
cdef double cy_gradient(self, double y_true, double raw_prediction) noexcept nogil
31+
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) noexcept nogil
3232

3333

3434
cdef class CyAbsoluteError(CyLossFunction):
35-
cdef double cy_loss(self, double y_true, double raw_prediction) nogil
36-
cdef double cy_gradient(self, double y_true, double raw_prediction) nogil
37-
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) nogil
35+
cdef double cy_loss(self, double y_true, double raw_prediction) noexcept nogil
36+
cdef double cy_gradient(self, double y_true, double raw_prediction) noexcept nogil
37+
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) noexcept nogil
3838

3939

4040
cdef class CyPinballLoss(CyLossFunction):
4141
cdef readonly double quantile # readonly makes it accessible from Python
42-
cdef double cy_loss(self, double y_true, double raw_prediction) nogil
43-
cdef double cy_gradient(self, double y_true, double raw_prediction) nogil
44-
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) nogil
42+
cdef double cy_loss(self, double y_true, double raw_prediction) noexcept nogil
43+
cdef double cy_gradient(self, double y_true, double raw_prediction) noexcept nogil
44+
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) noexcept nogil
4545

4646

4747
cdef class CyHalfPoissonLoss(CyLossFunction):
48-
cdef double cy_loss(self, double y_true, double raw_prediction) nogil
49-
cdef double cy_gradient(self, double y_true, double raw_prediction) nogil
50-
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) nogil
48+
cdef double cy_loss(self, double y_true, double raw_prediction) noexcept nogil
49+
cdef double cy_gradient(self, double y_true, double raw_prediction) noexcept nogil
50+
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) noexcept nogil
5151

5252

5353
cdef class CyHalfGammaLoss(CyLossFunction):
54-
cdef double cy_loss(self, double y_true, double raw_prediction) nogil
55-
cdef double cy_gradient(self, double y_true, double raw_prediction) nogil
56-
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) nogil
54+
cdef double cy_loss(self, double y_true, double raw_prediction) noexcept nogil
55+
cdef double cy_gradient(self, double y_true, double raw_prediction) noexcept nogil
56+
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) noexcept nogil
5757

5858

5959
cdef class CyHalfTweedieLoss(CyLossFunction):
6060
cdef readonly double power # readonly makes it accessible from Python
61-
cdef double cy_loss(self, double y_true, double raw_prediction) nogil
62-
cdef double cy_gradient(self, double y_true, double raw_prediction) nogil
63-
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) nogil
61+
cdef double cy_loss(self, double y_true, double raw_prediction) noexcept nogil
62+
cdef double cy_gradient(self, double y_true, double raw_prediction) noexcept nogil
63+
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) noexcept nogil
6464

6565

6666
cdef class CyHalfTweedieLossIdentity(CyLossFunction):
6767
cdef readonly double power # readonly makes it accessible from Python
68-
cdef double cy_loss(self, double y_true, double raw_prediction) nogil
69-
cdef double cy_gradient(self, double y_true, double raw_prediction) nogil
70-
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) nogil
68+
cdef double cy_loss(self, double y_true, double raw_prediction) noexcept nogil
69+
cdef double cy_gradient(self, double y_true, double raw_prediction) noexcept nogil
70+
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) noexcept nogil
7171

7272

7373
cdef class CyHalfBinomialLoss(CyLossFunction):
74-
cdef double cy_loss(self, double y_true, double raw_prediction) nogil
75-
cdef double cy_gradient(self, double y_true, double raw_prediction) nogil
76-
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) nogil
74+
cdef double cy_loss(self, double y_true, double raw_prediction) noexcept nogil
75+
cdef double cy_gradient(self, double y_true, double raw_prediction) noexcept nogil
76+
cdef double_pair cy_grad_hess(self, double y_true, double raw_prediction) noexcept nogil

0 commit comments

Comments
 (0)
0