Skip to content

Commit

Permalink
test no numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
jagerber48 committed Nov 4, 2024
1 parent 6fba94b commit 22e1b52
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion tests/test_uncertainties.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import copy
import math
import random # noqa
from unittest.mock import patch

import pytest

import uncertainties.core as uncert_core
from uncertainties.core import ufloat, AffineScalarFunc, ufloat_fromstr
from uncertainties import umath
from uncertainties import (
umath,
correlated_values,
correlated_values_norm,
correlation_matrix,
)
from helpers import (
power_special_cases,
power_all_cases,
Expand Down Expand Up @@ -1313,3 +1321,39 @@ def test_correlated_values_correlation_mat():
numpy.array(cov_mat),
numpy.array(uncert_core.covariance_matrix([x2, y2, z2])),
)


@patch("uncertainties.core.numpy", None)
def test_no_numpy():
nom_values = [1, 2, 3]
std_devs = [0.1, 0.2, 0.3]
cov = [
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
]

with pytest.raises(
NotImplementedError,
match="not able to import numpy",
):
_ = correlated_values(nom_values, cov)

with pytest.raises(
NotImplementedError,
match="not able to import numpy",
):
_ = correlated_values_norm(
list(zip(nom_values, std_devs)),
cov,
)

x = ufloat(1, 0.1)
y = ufloat(2, 0.2)
z = ufloat(3, 0.3)

with pytest.raises(
NotImplementedError,
match="not able to import numpy",
):
_ = correlation_matrix([x, y, z])

0 comments on commit 22e1b52

Please sign in to comment.