Skip to content

Commit

Permalink
uarrays_close
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgsavage committed Apr 3, 2024
1 parent e882aad commit 7c46845
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion tests/test_ulinalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
sys.exit() # There is no reason to test the interface to NumPy

from uncertainties import unumpy, ufloat
from uncertainties.testing import uuarrays_close
from uncertainties.testing import uarrays_close

def test_list_inverse():
"Test of the inversion of a square matrix"
Expand Down
34 changes: 17 additions & 17 deletions tests/test_uncertainties.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import uncertainties.core as uncert_core
from uncertainties.core import ufloat, AffineScalarFunc, ufloat_fromstr
from uncertainties import umath
from uncertainties.testing import numbers_close, ufloats_close, compare_derivatives, arrays_close
from uncertainties.testing import numbers_close, ufloats_close, compare_derivatives, uarrays_close
from helpers import power_special_cases, power_all_cases, power_wrt_ref


Expand Down Expand Up @@ -1796,7 +1796,7 @@ def test_correlated_values():
covs = uncert_core.covariance_matrix([x, y, z])

# Test of the diagonal covariance elements:
assert arrays_close(
assert uarrays_close(
numpy.array([v.std_dev**2 for v in (x, y, z)]),
numpy.array(covs).diagonal())

Expand All @@ -1808,15 +1808,15 @@ def test_correlated_values():
tags = ['x', 'y', 'z'])

# Even the uncertainties should be correctly reconstructed:
assert arrays_close(numpy.array((x, y, z)),
assert uarrays_close(numpy.array((x, y, z)),
numpy.array((x_new, y_new, z_new)))

# ... and the covariances too:
assert arrays_close(
assert uarrays_close(
numpy.array(covs),
numpy.array(uncert_core.covariance_matrix([x_new, y_new, z_new])))

assert arrays_close(
assert uarrays_close(
numpy.array([z_new]), numpy.array([-3*x_new+y_new]))

####################
Expand All @@ -1836,12 +1836,12 @@ def test_correlated_values():
[x.nominal_value for x in [u, v, sum_value]],
cov_matrix)

# arrays_close() is used instead of numbers_close() because
# uarrays_close() is used instead of numbers_close() because
# it compares uncertainties too:
assert arrays_close(numpy.array([u]), numpy.array([u2]))
assert arrays_close(numpy.array([v]), numpy.array([v2]))
assert arrays_close(numpy.array([sum_value]), numpy.array([sum2]))
assert arrays_close(numpy.array([0]),
assert uarrays_close(numpy.array([u]), numpy.array([u2]))
assert uarrays_close(numpy.array([v]), numpy.array([v2]))
assert uarrays_close(numpy.array([sum_value]), numpy.array([sum2]))
assert uarrays_close(numpy.array([0]),
numpy.array([sum2-(u2+2*v2)]))


Expand Down Expand Up @@ -1885,7 +1885,7 @@ def test_correlated_values():
assert numbers_close(variable.n, nom_value)
assert numbers_close(variable.s**2, variance)

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

Expand Down Expand Up @@ -1920,18 +1920,18 @@ def test_correlated_values_correlation_mat():
x2, y2, z2 = uncert_core.correlated_values_norm(
list(zip(nominal_values, std_devs)), corr_mat)

# arrays_close() is used instead of numbers_close() because
# uarrays_close() is used instead of numbers_close() because
# it compares uncertainties too:

# Test of individual variables:
assert arrays_close(numpy.array([x]), numpy.array([x2]))
assert arrays_close(numpy.array([y]), numpy.array([y2]))
assert arrays_close(numpy.array([z]), numpy.array([z2]))
assert uarrays_close(numpy.array([x]), numpy.array([x2]))
assert uarrays_close(numpy.array([y]), numpy.array([y2]))
assert uarrays_close(numpy.array([z]), numpy.array([z2]))

# Partial correlation test:
assert arrays_close(numpy.array([0]), numpy.array([z2-(-3*x2+y2)]))
assert uarrays_close(numpy.array([0]), numpy.array([z2-(-3*x2+y2)]))

# Test of the full covariance matrix:
assert arrays_close(
assert uarrays_close(
numpy.array(cov_mat),
numpy.array(uncert_core.covariance_matrix([x2, y2, z2])))

0 comments on commit 7c46845

Please sign in to comment.