

def check_sparse_input(name, X, X_sparse, y):
    ForestEstimator = FOREST_ESTIMATORS[name]
    dense = ForestEstimator(random_state=0, max_depth=2).fit(X, y)
    sparse = ForestEstimator(random_state=0, max_depth=2).fit(X_sparse, y)
    assert_array_almost_equal(dense.apply(X), dense.apply(X))
    if ((name in FOREST_CLASSIFIERS) or (name in FOREST_REGRESSORS)):
        assert_array_almost_equal(sparse.predict(X), dense.predict(X))
        assert_array_almost_equal(sparse.feature_importances_, dense.feature_importances_)
    if (name in FOREST_CLASSIFIERS):
        assert_array_almost_equal(sparse.predict_proba(X), dense.predict_proba(X))
        assert_array_almost_equal(sparse.predict_log_proba(X), dense.predict_log_proba(X))
    if (name in FOREST_TRANSFORMERS):
        assert_array_almost_equal(sparse.transform(X).toarray(), dense.transform(X).toarray())
        assert_array_almost_equal(sparse.fit_transform(X).toarray(), dense.fit_transform(X).toarray())

dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/ensemble/tests/test_forest.py check_sparse_input/VarMisuse@65/93 `sparse`->`dense`