def test_check_sdp_from_eigen_positive_err_messages(): """Tests that if _check_sdp_from_eigen is given a negative tol it returns an error, and if positive (or None) it does not""" w = np.abs(np.random.RandomState(42).randn(10)) + 1 with pytest.raises(ValueError) as raised_error: _check_sdp_from_eigen(w, -5.) assert str(raised_error.value) == "tol should be positive." with pytest.raises(ValueError) as raised_error: _check_sdp_from_eigen(w, -1e-10) assert str(raised_error.value) == "tol should be positive." _check_sdp_from_eigen(w, 1.) _check_sdp_from_eigen(w, 0.) _check_sdp_from_eigen(w, None)
def test__check_sdp_from_eigen_positive_err_messages(): """Tests that if _check_sdp_from_eigen is given a negative tol it returns an error, and if positive (or None) it does not""" w = np.abs(np.random.RandomState(42).randn(10)) + 1 with pytest.raises(ValueError) as raised_error: _check_sdp_from_eigen(w, -5.) assert str(raised_error.value) == "tol should be positive." with pytest.raises(ValueError) as raised_error: _check_sdp_from_eigen(w, -1e-10) assert str(raised_error.value) == "tol should be positive." _check_sdp_from_eigen(w, 1.) _check_sdp_from_eigen(w, 0.) _check_sdp_from_eigen(w, None)
def test__check_sdp_from_eigen_returns_definiteness(w, is_definite): """Tests that _check_sdp_from_eigen returns the definiteness of the matrix (when it is PSD), based on the given eigenvalues""" assert _check_sdp_from_eigen(w) == is_definite
def test__check_sdp_from_eigen_negative_eigenvalues(w): """Tests that _check_sdp_from_eigen, returns no error when the eigenvalues are positive.""" _check_sdp_from_eigen(w)
def test__check_sdp_from_eigen_positive_eigenvalues(w): """Tests that _check_sdp_from_eigen, returns a NonPSDError when the eigenvalues are negatives or null.""" with pytest.raises(NonPSDError): _check_sdp_from_eigen(w)