Skip to content
Merged
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
2 changes: 1 addition & 1 deletion sklearn/neighbors/_quad_tree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ cdef class _QuadTree:
if capacity == self.capacity and self.cells != NULL:
return 0

if capacity == SIZE_MAX:
if <size_t> capacity == SIZE_MAX:
Copy link
Member

Choose a reason for hiding this comment

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

Another alternative which is:

        if capacity == <SIZE_t> SIZE_MAX:

but I think what you chose brings a correct conversion: capacity is SIZE_t AKA cnp.npy_intp AKA Py_intptr_t AKA "an integer that is the size of a pointer on the platform" whilst, SIZE_MAX is the maximum value for uint64 stored as a uint64 I suppose.

I find using SIZE_MAX for this encoding weird. Would there be configuration for which this would break? Previously, was capacity cast to a size_t (likely a uint64 on most architecture nowadays) or was SIZE_MAX cast to a Py_intptr_t?

@OmarManzoor: can you provide the warning you get on your platform?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the precise warning:
sklearn/neighbors/_quad_tree.c:8389:34: warning: comparison of integers of different signs: '__pyx_t_7sklearn_9neighbors_10_quad_tree_SIZE_t' (aka 'long') and 'unsigned long' [-Wsign-compare] __pyx_t_1 = ((__pyx_v_capacity == SIZE_MAX) != 0);

if self.capacity == 0:
capacity = 9 # default initial value to min
else:
Expand Down