From 5865f1a42ebf367e21a8038579722c7e365c57e0 Mon Sep 17 00:00:00 2001 From: Scott Gigante Date: Sat, 12 Oct 2019 18:27:29 -0400 Subject: [PATCH] add tests --- test/test_data.py | 5 +++++ test/test_knn.py | 8 ++++++++ test/test_mnn.py | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/test/test_data.py b/test/test_data.py index 3095475..f809478 100644 --- a/test/test_data.py +++ b/test/test_data.py @@ -65,6 +65,11 @@ def test_badstring_rank_threshold(): build_graph(data, n_pca=True, rank_threshold='foobar') +@raises(ValueError) +def test_negative_rank_threshold(): + build_graph(data, n_pca=True, rank_threshold=-1) + + @raises(ValueError) @warns(RuntimeWarning) def test_True_n_pca_large_threshold(): diff --git a/test/test_knn.py b/test/test_knn.py index a78a3dc..52e0223 100644 --- a/test/test_knn.py +++ b/test/test_knn.py @@ -380,6 +380,14 @@ def test_shortest_path_precomputed_no_decay_data(): G.shortest_path(distance='data') +@raises(ValueError) +def test_shortest_path_invalid(): + data_small = data[np.random.choice( + len(data), len(data) // 4, replace=False)] + G = build_graph(data_small, knn=5, decay=None) + G.shortest_path(distance='invalid') + + #################### # Test API #################### diff --git a/test/test_mnn.py b/test/test_mnn.py index 2dd6465..0e91aa4 100644 --- a/test/test_mnn.py +++ b/test/test_mnn.py @@ -116,6 +116,16 @@ def test_mnn_with_kernel_symm_gamma(): theta=0.9) +@raises(ValueError) +def test_mnn_with_kernel_symm_invalid(): + build_graph( + data, thresh=0, n_pca=20, + decay=10, knn=5, random_state=42, + sample_idx=digits['target'], + kernel_symm='invalid', + theta=0.9) + + @warns(FutureWarning) def test_mnn_with_kernel_symm_theta(): build_graph(