Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e145071

Browse filesBrowse files
committed
Fixed
Signed-off-by: Adam Li <adam2392@gmail.com>
1 parent 4ff92e0 commit e145071
Copy full SHA for e145071

Some content is hidden

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

58 files changed

+638
-598
lines changed

‎replace.py

Copy file name to clipboard
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import re
2+
from pathlib import Path
3+
from itertools import chain
4+
5+
sklearn_root = Path("./sklearn")
6+
7+
pyx_paths = chain(
8+
sklearn_root.glob("**/*.pyx"),
9+
sklearn_root.glob("**/*.pyx.tp"),
10+
sklearn_root.glob("**/*.pxi"),
11+
)
12+
13+
14+
nogil_colon = re.compile(r"\) nogil:")
15+
nogil_except_neg1 = re.compile(r"\) nogil except -1:")
16+
nogil_except_star = re.compile(r"\) nogil except [*]:")
17+
18+
for pyx_path in pyx_paths:
19+
orig_contents = pyx_path.read_text()
20+
new_contents = nogil_colon.sub(") noexcept nogil:", orig_contents)
21+
new_contents = nogil_except_neg1.sub(") except -1 nogil:", new_contents)
22+
new_contents = nogil_except_star.sub(") except * nogil:", new_contents)
23+
24+
if new_contents != orig_contents:
25+
pyx_path.write_text(new_contents)
26+
27+
28+
nogil_no_colon = re.compile(r"\) nogil\n")
29+
nogil_except_neg1_no_colon = re.compile(r"\) nogil except -1")
30+
nogil_except_star_no_colon = re.compile(r"\) nogil except \*")
31+
pxd_paths = chain(sklearn_root.glob("**/*.pxd"), sklearn_root.glob("**/*.pxd.tp"))
32+
33+
for pxd_path in pxd_paths:
34+
orig_contents = pxd_path.read_text()
35+
new_contents = nogil_no_colon.sub(") noexcept nogil\n", orig_contents)
36+
new_contents = nogil_except_neg1_no_colon.sub(") except -1 nogil", new_contents)
37+
new_contents = nogil_except_star_no_colon.sub(") except * nogil", new_contents)
38+
39+
if new_contents != orig_contents:
40+
pxd_path.write_text(new_contents)

‎sklearn/_loss/_loss.pxd

Copy file name to clipboardExpand all lines: sklearn/_loss/_loss.pxd
+27-27Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.