Skip to content

Commit 1b2b871

Browse files
authored
TST Extend tests for scipy.sparse.*array in test_lof.py (scikit-learn#27162)
1 parent dea72cc commit 1b2b871

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sklearn/neighbors/tests/test_lof.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import numpy as np
99
import pytest
10-
from scipy.sparse import csr_matrix
1110

1211
from sklearn import metrics, neighbors
1312
from sklearn.datasets import load_iris
@@ -18,6 +17,7 @@
1817
check_outlier_corruption,
1918
parametrize_with_checks,
2019
)
20+
from sklearn.utils.fixes import CSR_CONTAINERS
2121

2222
# load the iris dataset
2323
# and randomly permute it
@@ -238,11 +238,12 @@ def test_predicted_outlier_number(expected_outliers):
238238
check_outlier_corruption(num_outliers, expected_outliers, y_dec)
239239

240240

241-
def test_sparse():
241+
@pytest.mark.parametrize("csr_container", CSR_CONTAINERS)
242+
def test_sparse(csr_container):
242243
# LocalOutlierFactor must support CSR inputs
243244
# TODO: compare results on dense and sparse data as proposed in:
244245
# https://github.com/scikit-learn/scikit-learn/pull/23585#discussion_r968388186
245-
X = csr_matrix(iris.data)
246+
X = csr_container(iris.data)
246247

247248
lof = neighbors.LocalOutlierFactor(novelty=True)
248249
lof.fit(X)

0 commit comments

Comments
 (0)