Skip to content

MAINT Use C99 functions from Cython #15098

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 3 commits into from
Sep 29, 2019

Conversation

rth
Copy link
Member

@rth rth commented Sep 26, 2019

Removes some hacks and re-implementations for older MSVC compilers than should no longer be necessary since we dropped Python <3.5

# XXX using (size_t)(-1) is ugly, but SIZE_MAX is not available in C89
# (i.e., older MSVC).
cdef SIZE_t DEFAULT = <SIZE_t>(-1)
cdef SIZE_t DEFAULT = SIZE_MAX
Copy link
Member Author

Choose a reason for hiding this comment

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

I think the referenced SIZE_MAX is the one from stdint.h but I would appreciate is someone could double-check.

Copy link
Member

Choose a reason for hiding this comment

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

I can confirm it is defined there: https://en.cppreference.com/w/c/types/limits

Can we use SIZE_MAX directly in this file instead of defining a DEFAULT?

@@ -279,7 +275,7 @@ cdef class _QuadTree:
cdef bint res = True
for i in range(self.n_dimensions):
# Use EPSILON to avoid numerical error that would overgrow the tree
res &= fabsf(point1[i] - point2[i]) <= EPSILON
res &= fabs(point1[i] - point2[i]) <= EPSILON
Copy link
Member

Choose a reason for hiding this comment

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

we're using double not instead of float? is there no fabsf in libc.math?

Copy link
Member Author

Choose a reason for hiding this comment

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

My mistake. fabsf is in math.h but for some reason not re-exported in cython's libc.math I think. Reverted that particular change.

@rth
Copy link
Member Author

rth commented Sep 28, 2019

Can we use SIZE_MAX directly in this file instead of defining a DEFAULT?

Sure done.

Another easy and related PR is #15097

@thomasjpfan thomasjpfan merged commit af8a6e5 into scikit-learn:master Sep 29, 2019
@thomasjpfan
Copy link
Member

Thank you @rth !

@rth rth deleted the rm-cython-depr-helpers branch September 29, 2019 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants