

def check_min_samples_leaf(name):
    (X, y) = (hastie_X, hastie_y)
    ForestEstimator = FOREST_ESTIMATORS[name]
    assert_raises(ValueError, ForestEstimator(min_samples_leaf=(- 1)).fit, X, y)
    assert_raises(ValueError, ForestEstimator(min_samples_leaf=0).fit, X, y)
    est = ForestEstimator(min_samples_leaf=5, n_estimators=1, random_state=0)
    est.fit(X, y)
    out = est.estimators_[0].tree_.apply(X)
    node_counts = bincount(out)
    leaf_count = node_counts[(node_counts != 0)]
    assert_greater(np.min(leaf_count), 4, 'Failed with {0}'.format(name))
    est = ForestEstimator(min_samples_leaf=0.25, n_estimators=1, random_state=0)
    est.fit(X, y)
    out = est.estimators_[0].tree_.apply(X)
    node_counts = np.bincount(out)
    leaf_count = node_counts[(node_counts != 0)]
    assert_greater(np.min(leaf_count), ((len(X) * 0.25) - 1), 'Failed with {0}'.format(name))

dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/ensemble/tests/test_forest.py check_min_samples_leaf/original