diff --git a/sklearn/linear_model/_cd_fast.pyx b/sklearn/linear_model/_cd_fast.pyx index 3b0b2251abf69..38ba169ae8015 100644 --- a/sklearn/linear_model/_cd_fast.pyx +++ b/sklearn/linear_model/_cd_fast.pyx @@ -32,7 +32,9 @@ cdef enum: # Max value for our rand_r replacement (near the bottom). # We don't use RAND_MAX because it's different across platforms and # particularly tiny on Windows/MSVC. - RAND_R_MAX = 0x7FFFFFFF + # It corresponds to the maximum representable value for + # 32-bit signed integers (i.e. 2^31 - 1). + RAND_R_MAX = 2147483647 cdef inline UINT32_t rand_int(UINT32_t end, UINT32_t* random_state) noexcept nogil: diff --git a/sklearn/tree/_criterion.pyx b/sklearn/tree/_criterion.pyx index 79f6346be239d..ed8a12065554e 100644 --- a/sklearn/tree/_criterion.pyx +++ b/sklearn/tree/_criterion.pyx @@ -236,7 +236,7 @@ cdef class Criterion: double upper_bound, double value_left, double value_right, - ) nogil: + ) noexcept nogil: cdef: bint check_lower_bound = ( (value_left >= lower_bound) & diff --git a/sklearn/tree/_utils.pxd b/sklearn/tree/_utils.pxd index 4938d3030245f..4b953af2d9b2b 100644 --- a/sklearn/tree/_utils.pxd +++ b/sklearn/tree/_utils.pxd @@ -23,7 +23,9 @@ cdef enum: # Max value for our rand_r replacement (near the bottom). # We don't use RAND_MAX because it's different across platforms and # particularly tiny on Windows/MSVC. - RAND_R_MAX = 0x7FFFFFFF + # It corresponds to the maximum representable value for + # 32-bit signed integers (i.e. 2^31 - 1). + RAND_R_MAX = 2147483647 # safe_realloc(&p, n) resizes the allocation of p to n * sizeof(*p) bytes or diff --git a/sklearn/utils/_random.pxd b/sklearn/utils/_random.pxd index 89741ea38179c..b5199fc506f4e 100644 --- a/sklearn/utils/_random.pxd +++ b/sklearn/utils/_random.pxd @@ -14,7 +14,7 @@ cdef enum: # particularly tiny on Windows/MSVC. # It corresponds to the maximum representable value for # 32-bit signed integers (i.e. 2^31 - 1). - RAND_R_MAX = 0x7FFFFFFF + RAND_R_MAX = 2147483647 cpdef sample_without_replacement(cnp.int_t n_population, cnp.int_t n_samples,