8000 Adds a test to ensure the parameter n_iter_without_progress is used c… · scikit-learn/scikit-learn@2d41da7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2d41da7

Browse files
author
Sebastian Saeger
committed
Adds a test to ensure the parameter n_iter_without_progress is used correctly
1 parent e458796 commit 2d41da7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

sklearn/manifold/tests/test_t_sne.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,3 +542,24 @@ def test_index_offset():
542542
# Make sure translating between 1D and N-D indices are preserved
543543
assert_equal(_barnes_hut_tsne.test_index2offset(), 1)
544544
assert_equal(_barnes_hut_tsne.test_index_offset(), 1)
545+
546+
547+
def test_n_iter_without_progress():
548+
# Make sure that the parameter n_iter_without_progress is used correctly
549+
random_state = check_random_state(0)
550+
X = random_state.randn(100, 2)
551+
tsne = TSNE(n_iter_without_progress=2, verbose=2,
552+
random_state=0, method='exact')
553+
554+
old_stdout = sys.stdout
555+
sys.stdout = StringIO()
556+
try:
557+
tsne.fit_transform(X)
558+
finally:
559+
out = sys.stdout.getvalue()
560+
sys.stdout.close()
561+
sys.stdout = old_stdout
562+
563+
# The output needs to contain the value of n_iter_without_progress
564+
assert("did not make any progress during the "
565+
"last 2 episodes. Finished." in out)

0 commit comments

Comments
 (0)
0