Skip to content

Commit 08658c6

Browse files
committed
Simplify cython partition api
Signed-off-by: Adam Li <adam2392@gmail.com>
1 parent ba18c4d commit 08658c6

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

sklearn/tree/_splitter.pyx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,17 @@ cdef inline intp_t node_split_best(
418418
Criterion criterion,
419419
SplitRecord* split,
420420
ParentInfo* parent_record,
421-
bint with_monotonic_cst,
422-
const int8_t[:] monotonic_cst,
421+
# bint with_monotonic_cst,
422+
# const int8_t[:] monotonic_cst,
423423
) except -1 nogil:
424424
"""Find the best split on node samples[start:end]
425425
426426
Returns -1 in case of failure to allocate memory (and raise MemoryError)
427427
or 0 otherwise.
428428
"""
429+
cdef const int8_t[:] monotonic_cst = splitter.monotonic_cst
430+
cdef bint with_monotonic_cst = splitter.with_monotonic_cst
431+
429432
# Find the best split
430433
cdef intp_t start = splitter.start
431434
cdef intp_t end = splitter.end
@@ -809,14 +812,15 @@ cdef inline int node_split_random(
809812
Criterion criterion,
810813
SplitRecord* split,
811814
ParentInfo* parent_record,
812-
bint with_monotonic_cst,
813-
const int8_t[:] monotonic_cst,
814815
) except -1 nogil:
815816
"""Find the best random split on node samples[start:end]
816817
817818
Returns -1 in case of failure to allocate memory (and raise MemoryError)
818819
or 0 otherwise.
819820
"""
821+
cdef const int8_t[:] monotonic_cst = splitter.monotonic_cst
822+
cdef bint with_monotonic_cst = splitter.with_monotonic_cst
823+
820824
# Draw random splits and pick the best
821825
cdef intp_t start = splitter.start
822826
cdef intp_t end = splitter.end
@@ -1662,8 +1666,6 @@ cdef class BestSplitter(Splitter):
16621666
self.criterion,
16631667
split,
16641668
parent_record,
1665-
self.with_monotonic_cst,
1666-
self.monotonic_cst,
16671669
)
16681670

16691671
cdef class BestSparseSplitter(Splitter):
@@ -1692,8 +1694,6 @@ cdef class BestSparseSplitter(Splitter):
16921694
self.criterion,
16931695
split,
16941696
parent_record,
1695-
self.with_monotonic_cst,
1696-
self.monotonic_cst,
16971697
)
16981698

16991699
cdef class RandomSplitter(Splitter):
@@ -1722,8 +1722,6 @@ cdef class RandomSplitter(Splitter):
17221722
self.criterion,
17231723
split,
17241724
parent_record,
1725-
self.with_monotonic_cst,
1726-
self.monotonic_cst,
17271725
)
17281726

17291727
cdef class RandomSparseSplitter(Splitter):
@@ -1751,6 +1749,4 @@ cdef class RandomSparseSplitter(Splitter):
17511749
self.criterion,
17521750
split,
17531751
parent_record,
1754-
self.with_monotonic_cst,
1755-
self.monotonic_cst,
17561752
)

0 commit comments

Comments
 (0)