Skip to content

Commit 8041f27

Browse files
jeremiedbbpunndcoder28
authored andcommitted
MAINT fix cython 3 compilation errors (scikit-learn#26771)
1 parent 21a4e2f commit 8041f27

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

sklearn/linear_model/_cd_fast.pyx

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ cdef enum:
3232
# Max value for our rand_r replacement (near the bottom).
3333
# We don't use RAND_MAX because it's different across platforms and
3434
# particularly tiny on Windows/MSVC.
35-
RAND_R_MAX = 0x7FFFFFFF
35+
# It corresponds to the maximum representable value for
36+
# 32-bit signed integers (i.e. 2^31 - 1).
37+
RAND_R_MAX = 2147483647
3638

3739

3840
cdef inline UINT32_t rand_int(UINT32_t end, UINT32_t* random_state) noexcept nogil:

sklearn/tree/_criterion.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ cdef class Criterion:
236236
double upper_bound,
237237
double value_left,
238238
double value_right,
239-
) nogil:
239+
) noexcept nogil:
240240
cdef:
241241
bint check_lower_bound = (
242242
(value_left >= lower_bound) &

sklearn/tree/_utils.pxd

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ cdef enum:
2323
# Max value for our rand_r replacement (near the bottom).
2424
# We don't use RAND_MAX because it's different across platforms and
2525
# particularly tiny on Windows/MSVC.
26-
RAND_R_MAX = 0x7FFFFFFF
26+
# It corresponds to the maximum representable value for
27+
# 32-bit signed integers (i.e. 2^31 - 1).
28+
RAND_R_MAX = 2147483647
2729

2830

2931
# safe_realloc(&p, n) resizes the allocation of p to n * sizeof(*p) bytes or

sklearn/utils/_random.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cdef enum:
1414
# particularly tiny on Windows/MSVC.
1515
# It corresponds to the maximum representable value for
1616
# 32-bit signed integers (i.e. 2^31 - 1).
17-
RAND_R_MAX = 0x7FFFFFFF
17+
RAND_R_MAX = 2147483647
1818

1919
cpdef sample_without_replacement(cnp.int_t n_population,
2020
cnp.int_t n_samples,

0 commit comments

Comments
 (0)