From cc0db493ff1b32a4737e9e385185a5c94fe43799 Mon Sep 17 00:00:00 2001 From: SIKAI ZHANG <34108862+MatthewSZhang@users.noreply.github.com> Date: Fri, 2 Aug 2024 17:22:53 +0800 Subject: [PATCH] MNT fix zero vector test --- tests/test_correlation.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/test_correlation.py b/tests/test_correlation.py index 77d22ea..b1dda8c 100644 --- a/tests/test_correlation.py +++ b/tests/test_correlation.py @@ -201,28 +201,27 @@ def test_cython_errors(): y = rng.random((n_samples)) - selector_zero_vector = FastCan( + selector_no_cand = FastCan( n_features_to_select=n_informative+1, ) + selector_const_vector = FastCan( + n_features_to_select=2, + ) with pytest.raises( ZeroDivisionError, match="Cannot normalize a vector of all zeros." ): # Zeros vector during orthogonalization - selector_zero_vector.fit(np.c_[x_sub, x_sub[:, 0]], y) + selector_const_vector.fit(np.zeros((3, 2)), [0, 0, 0]) with pytest.raises( ZeroDivisionError, match="Cannot normalize a matrix containing a vector of all zeros." ): # Constant vector - selector_const_vector = FastCan( - n_features_to_select=2, - ) selector_const_vector.fit(np.zeros((3, 2)), [1, 2, 3]) with pytest.raises(RuntimeError, match=r"No candidate feature can .*"): # No candidate - selector_zero_vector.fit(np.c_[x_sub, x_sub[:, 0]+x_sub[:, 1]], y) - + selector_no_cand.fit(np.c_[x_sub, x_sub[:, 0]+x_sub[:, 1]], y)