Skip to content

Commit

Permalink
MAINT Remove unnecessary check in tree.pyx (scikit-learn#30474)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremiedbb authored Dec 15, 2024
1 parent 21c2d29 commit 6922bf0
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions sklearn/tree/_tree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,7 @@ cdef class TreeBuilder:
# since we have to copy we will make it fortran for efficiency
X = np.asfortranarray(X, dtype=DTYPE)

# TODO: This check for y seems to be redundant, as it is also
# present in the BaseDecisionTree's fit method, and therefore
# can be removed.
if y.base.dtype != DOUBLE or not y.base.flags.contiguous:
y = np.ascontiguousarray(y, dtype=DOUBLE)

if (
sample_weight is not None and
(
sample_weight.base.dtype != DOUBLE or
not sample_weight.base.flags.contiguous
)
):
if sample_weight is not None and not sample_weight.base.flags.contiguous:
sample_weight = np.asarray(sample_weight, dtype=DOUBLE, order="C")

return X, y, sample_weight
Expand Down

0 comments on commit 6922bf0

Please sign in to comment.