8000 TST Add non-regression test for #7981 · jjerphan/scikit-learn@15f39d1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 15f39d1

Browse files
jjerphanlesteve
andcommitted
TST Add non-regression test for scikit-learn#7981
This reproducer is adapted from the one of this message: scikit-learn#7981 (comment) Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
1 parent d431d7e commit 15f39d1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

sklearn/metrics/tests/test_pairwise.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from types import GeneratorType
33

44
import numpy as np
5+
from joblib import Parallel
56
from numpy import linalg
67

78
from scipy.sparse import dok_matrix, csr_matrix, issparse
@@ -15,7 +16,7 @@
1516
# should be used instead.
1617
from scipy.spatial.distance import minkowski as wminkowski
1718

18-
from sklearn.utils.fixes import sp_version, parse_version
19+
from sklearn.utils.fixes import sp_version, parse_version, delayed
1920

2021
import pytest
2122

@@ -1549,3 +1550,14 @@ def test_numeric_pairwise_distances_datatypes(metric, global_dtype, y_is_x):
15491550
dist = pairwise_distances(X, Y, metric=metric, **params)
15501551

15511552
assert_allclose(dist, expected_dist)
1553+
1554+
1555+
def test_sparse_manhattan_readonly_dataset():
1556+
# Non-regression test for: https://github.com/scikit-learn/scikit-learn/issues/7981
1557+
matrices1 = [csr_matrix(np.ones((5, 5)))]
1558+
matrices2 = [csr_matrix(np.ones((5, 5)))]
1559+
# Joblib memory maps datasets which makes them read only.
1560+
# The following call was reporting as failing in 7981, but this must pass.
1561+
Parallel(n_jobs=-1, max_nbytes=0)(
1562+
delayed(manhattan_distances)(m1, m2) for m1, m2 in zip(matrices1, matrices2)
1563+
)

0 commit comments

Comments
 (0)
0