8000 fix kernel approximation test · scikit-learn/scikit-learn@3afc42b · GitHub
[go: up one dir, main page]

Skip to content

Commit 3afc42b

Browse files
committed
fix kernel approximation test
1 parent 45289e8 commit 3afc42b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sklearn/tests/test_kernel_approximation.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
from scipy.sparse import csr_matrix
3+
import pytest
34

45
from sklearn.utils.testing import assert_array_equal, assert_equal, assert_true
56
from sklearn.utils.testing import assert_not_equal
@@ -244,3 +245,14 @@ def logging_histogram_kernel(x, y, log):
244245
n_components=(n_samples - 1),
245246
kernel_params={'log': kernel_log}).fit(X)
246247
assert_equal(len(kernel_log), n_samples * (n_samples - 1) / 2)
248+
249+
def linear_kernel(X, Y):
250+
return np.dot(X, Y.T)
251+
252+
# if degree, gamma or coef0 is passed, we raise a warning
253+
msg = "Don't pass gamma, coef0 or degree to Nystroem"
254+
params = ({'gamma': 1}, {'coef0': 1}, {'degree': 2})
255+
for param in params:
256+
ny = Nystroem(kernel=linear_kernel, **param)
257+
with pytest.raises(ValueError, match=msg):
258+
ny.fit(X)

0 commit comments

Comments
 (0)
0