Skip to content

Commit

Permalink
Removed two unused imports in two tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
willynilly committed Mar 31, 2024
1 parent e9b82f0 commit 7d04e32
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 97 deletions.
20 changes: 14 additions & 6 deletions uncertainties/test_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from __future__ import absolute_import

# Standard modules
import sys
import math

# Local modules:
Expand All @@ -23,6 +22,7 @@
###############################################################################
# Unit tests


def test_fixed_derivatives_math_funcs():
"""
Comparison between function derivatives and numerical derivatives.
Expand All @@ -45,6 +45,7 @@ def test_fixed_derivatives_math_funcs():
# modf(): returns a tuple:
def frac_part_modf(x):
return umath_core.modf(x)[0]

def int_part_modf(x):
return umath_core.modf(x)[1]

Expand All @@ -61,6 +62,7 @@ def int_part_modf(x):
# frexp(): returns a tuple:
def mantissa_frexp(x):
return umath_core.frexp(x)[0]

def exponent_frexp(x):
return umath_core.frexp(x)[1]

Expand All @@ -73,6 +75,7 @@ def exponent_frexp(x):
uncert_core.NumericalDerivatives(
lambda x: exponent_frexp(x)))


def test_compound_expression():
"""
Test equality between different formulas.
Expand All @@ -97,7 +100,8 @@ def test_numerical_example():
== "0.001593 +/- 0.010000")

# Regular calculations should still work:
assert("%.11f" % umath_core.sin(3) == "0.14112000806")
assert ("%.11f" % umath_core.sin(3) == "0.14112000806")


def test_monte_carlo_comparison():
"""
Expand Down Expand Up @@ -159,8 +163,7 @@ def monte_carlo_calc(n_samples):

(nominal_value_samples, covariances_samples) = monte_carlo_calc(1000000)


## Comparison between both results:
# Comparison between both results:

# The covariance matrices must be close:

Expand All @@ -180,7 +183,7 @@ def monte_carlo_calc(n_samples):
" the Monte-Carlo simulation and the direct calculation:\n"
"* Monte-Carlo:\n%s\n* Direct calculation:\n%s"
% (covariances_samples, covariances_this_module)
)
)

# The nominal values must be close:
assert test_uncertainties.numbers_close(
Expand All @@ -196,7 +199,7 @@ def monte_carlo_calc(n_samples):
% (nominal_value_this_module,
nominal_value_samples,
math.sqrt(covariances_samples[2, 2]))
)
)


def test_math_module():
Expand Down Expand Up @@ -270,6 +273,7 @@ def test_math_module():
else:
raise Exception('%s exception expected' % exception_class.__name__)


def test_hypot():
'''
Special cases where derivatives cannot be calculated:
Expand All @@ -282,6 +286,7 @@ def test_hypot():
assert test_uncertainties.isnan(result.derivatives[x])
assert test_uncertainties.isnan(result.derivatives[y])


def test_power_all_cases():
'''
Test special cases of umath_core.pow().
Expand All @@ -292,6 +297,8 @@ def test_power_all_cases():
# test_uncertainties.py:test_power_special_cases(), but with small
# differences: the built-in pow() and math.pow() are slightly
# different:


def test_power_special_cases():
'''
Checks special cases of umath_core.pow().
Expand Down Expand Up @@ -337,6 +344,7 @@ def test_power_special_cases():
else:
raise Exception('%s exception expected' % exception_class.__name__)


def test_power_wrt_ref():
'''
Checks special cases of the umath_core.pow() power operator.
Expand Down
Loading

0 comments on commit 7d04e32

Please sign in to comment.