Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed two unused imports in two tests. #209

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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