Skip to content

Commit b7e3b6e

Browse files
committed
COSMIT: intermediate variable
1 parent 0ee5568 commit b7e3b6e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sklearn/tree/tree.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -334,20 +334,21 @@ def recursive_partition(X, X_argsorted, y, sample_mask, depth,
334334
if y.dtype != DTYPE or not y.flags.contiguous:
335335
y = np.asarray(y, dtype=DTYPE, order="C")
336336

337+
n_samples = X.shape[0]
337338
if sample_mask is None:
338-
sample_mask = np.ones((X.shape[0],), dtype=np.bool)
339-
elif len(sample_mask) != len(y):
339+
sample_mask = np.ones((n_samples, ), dtype=np.bool)
340+
elif len(sample_mask) != n_samples:
340341
raise ValueError(
341342
"Length of sample_mask=%s does not match number of samples=%s"
342-
% (len(sample_mask), len(y)))
343+
% (len(sample_mask), n_samples))
343344

344345
if X_argsorted is None:
345346
X_argsorted = np.asfortranarray(
346347
np.argsort(X.T, axis=1).astype(np.int32).T)
347-
elif len(X_argsorted) != len(y):
348+
elif len(X_argsorted) != n_samples:
348349
raise ValueError(
349350
"Length of X_argsorted=%s does not match number of samples=%s"
350-
% (len(X_argsorted), len(y)))
351+
% (len(X_argsorted), n_samples))
351352

352353
# Pre-allocate some space
353354
if max_depth <= 10:

0 commit comments

Comments
 (0)