Skip to content

Commit f2136f4

Browse files
committed
Merge branch 'tree-featuresv2' of https://github.com/neurodata/scikit-learn into tree-featuresv2
2 parents a903c1c + 28d31e7 commit f2136f4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

sklearn/tree/_tree.pyx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ from cpython cimport Py_INCREF, PyObject, PyTypeObject
1717
from libc.stdlib cimport free
1818
from libc.string cimport memcpy
1919
from libc.string cimport memset
20-
from libc.stdint cimport SIZE_MAX
20+
from libc.stdint cimport INTPTR_MAX
21+
from libcpp.vector cimport vector
2122
from libcpp.algorithm cimport pop_heap
2223
from libcpp.algorithm cimport push_heap
2324
from libcpp cimport bool
@@ -252,7 +253,7 @@ cdef class DepthFirstTreeBuilder(TreeBuilder):
252253
impurity, n_node_samples,
253254
weighted_n_node_samples)
254255

255-
if node_id == SIZE_MAX:
256+
if node_id == INTPTR_MAX:
256257
rc = -1
257258
break
258259

@@ -492,7 +493,7 @@ cdef class BestFirstTreeBuilder(TreeBuilder):
492493
is_left, is_leaf,
493494
split_ptr, impurity, n_node_samples,
494495
weighted_n_node_samples)
495-
if node_id == SIZE_MAX:
496+
if node_id == INTPTR_MAX:
496497
return -1
497498

498499
# compute values also for split nodes (might become leafs later).
@@ -550,7 +551,7 @@ cdef class BaseTree:
550551

551552
cdef int _resize_c(
552553
self,
553-
SIZE_t capacity=SIZE_MAX
554+
SIZE_t capacity=INTPTR_MAX
554555
) nogil except -1:
555556
"""Guts of _resize
556557
@@ -560,7 +561,7 @@ cdef class BaseTree:
560561
if capacity == self.capacity and self.nodes != NULL:
561562
return 0
562563

563-
if capacity == SIZE_MAX:
564+
if capacity == INTPTR_MAX:
564565
if self.capacity == 0:
565566
capacity = 3 # default initial value
566567
else:
@@ -669,7 +670,7 @@ cdef class BaseTree:
669670

670671
if node_id >= self.capacity:
671672
if self._resize_c() != 0:
672-
return SIZE_MAX
673+
return INTPTR_MAX
673674

674675
cdef Node* node = &self.nodes[node_id]
675676
node.impurity = impurity
@@ -1901,7 +1902,7 @@ cdef _build_pruned_tree(
19011902
node.impurity, node.n_node_samples,
19021903
node.weighted_n_node_samples)
19031904

1904-
if new_node_id == SIZE_MAX:
1905+
if new_node_id == INTPTR_MAX:
19051906
rc = -1
19061907
break
19071908

0 commit comments

Comments
 (0)