Skip to content

MAINT fix cython 3 compilation errors #26771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sklearn/linear_model/_cd_fast.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you compares, if cd gives the same results?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc tests are meant to ensure that. Like the example in the docstring of GraphicalLasso, which uses enet_coordinate_descent.

also:

In [4]: %%cython
   ...: cdef enum:
   ...:     R = 0x7FFFFFFF
   ...: print(R)
   ...:
2147483647



cdef inline UINT32_t rand_int(UINT32_t end, UINT32_t* random_state) noexcept nogil:
Expand Down
2 changes: 1 addition & 1 deletion sklearn/tree/_criterion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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) &
Expand Down
4 changes: 3 additions & 1 deletion sklearn/tree/_utils.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sklearn/utils/_random.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down