Skip to content

Commit f01907d

Browse files
committed
TST upgrade trivial (single-class) k-NN problems to binary ones
XXX should we raise a warning/exception when there is only one class in y?
1 parent 9cfdff5 commit f01907d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sklearn/neighbors/tests/test_neighbors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def test_kneighbors_classifier(n_samples=40,
174174
"""Test k-neighbors classification"""
175175
rng = np.random.RandomState(random_state)
176176
X = 2 * rng.rand(n_samples, n_features) - 1
177-
y = ((X ** 2).sum(axis=1) < .25).astype(np.int)
177+
y = ((X ** 2).sum(axis=1) < .5).astype(np.int)
178178

179179
weight_func = _weight_func
180180

@@ -218,7 +218,7 @@ def test_radius_neighbors_classifier(n_samples=40,
218218
"""Test radius-based classification"""
219219
rng = np.random.RandomState(random_state)
220220
X = 2 * rng.rand(n_samples, n_features) - 1
221-
y = ((X ** 2).sum(axis=1) < .25).astype(np.int)
221+
y = ((X ** 2).sum(axis=1) < .5).astype(np.int)
222222

223223
weight_func = _weight_func
224224

@@ -312,7 +312,7 @@ def test_kneighbors_classifier_sparse(n_samples=40,
312312
# Like the above, but with various types of sparse matrices
313313
rng = np.random.RandomState(random_state)
314314
X = 2 * rng.rand(n_samples, n_features) - 1
315-
y = ((X ** 2).sum(axis=1) < .25).astype(np.int)
315+
y = ((X ** 2).sum(axis=1) < .5).astype(np.int)
316316

317317
SPARSE_TYPES = (bsr_matrix, coo_matrix, csc_matrix, csr_matrix,
318318
dok_matrix, lil_matrix)

0 commit comments

Comments
 (0)