Skip to content

Commit

Permalink
test error cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jagerber48 committed Nov 16, 2024
1 parent 004d323 commit 418326b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_uncertainties.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,28 @@ def test_correlated_values():

assert uarrays_close(cov, numpy.array(uncert_core.covariance_matrix(variables)))

nom_values = [0, 0, 0]
covariance_mat = numpy.diag([1, 1, -1])
with pytest.raises(
ValueError,
match="must be positive semi-definite.",
):
x, y, z = correlated_values(nom_values, covariance_mat)

covariance_mat = numpy.array([[1, 0, 1], [0, 1, 0], [0, 0, 1]])
with pytest.raises(
ValueError,
match="must be symmetric.",
):
x, y, z = correlated_values(nom_values, covariance_mat)

covariance_mat = numpy.array([[1, 0, 0], [0, 1j, 0], [0, 0, 1]])
with pytest.raises(
ValueError,
match="must be real.",
):
x, y, z = correlated_values(nom_values, covariance_mat)

def test_correlated_values_correlation_mat():
"""
Tests the input of correlated value.
Expand Down Expand Up @@ -1327,6 +1349,11 @@ def test_correlated_values_correlation_mat():
numpy.array(uncert_core.covariance_matrix([x2, y2, z2])),
)

values_with_std_dev = ((0, 1), (0, 1), (0, -1))
correlation_mat = np.diag((1, 1, 1))
with pytest.raises(ValueError, match="must be non-negative."):
x, y, z = correlated_values_norm(values_with_std_dev, correlation_mat)


@pytest.mark.skipif(
np is not None,
Expand Down

0 comments on commit 418326b

Please sign in to comment.