"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mpmath/tests/test_power.py" between
mpmath-0.18.tar.gz and mpmath-0.19.tar.gz

About: mpmath is a Python library for arbitrary-precision floating-point arithmetic.

test_power.py  (mpmath-0.18):test_power.py  (mpmath-0.19)
skipping to change at line 39 skipping to change at line 39
ab = a**b ab = a**b
# note: could actually be exact, but that's very unlikely! # note: could actually be exact, but that's very unlikely!
assert to_int(mpf_pow(from_int(a), from_int(b), prec, round_down)) < ab assert to_int(mpf_pow(from_int(a), from_int(b), prec, round_down)) < ab
assert to_int(mpf_pow(from_int(a), from_int(b), prec, round_up)) > a b assert to_int(mpf_pow(from_int(a), from_int(b), prec, round_up)) > a b
def test_pow_epsilon_rounding(): def test_pow_epsilon_rounding():
""" """
Stress test directed rounding for powers with integer exponents. Stress test directed rounding for powers with integer exponents.
Basically, we look at the following cases: Basically, we look at the following cases:
>>> 1.0001 ** -5 >>> 1.0001 ** -5 # doctest: +SKIP
0.99950014996500702 0.99950014996500702
>>> 0.9999 ** -5 >>> 0.9999 ** -5 # doctest: +SKIP
1.000500150035007 1.000500150035007
>>> (-1.0001) ** -5 >>> (-1.0001) ** -5 # doctest: +SKIP
-0.99950014996500702 -0.99950014996500702
>>> (-0.9999) ** -5 >>> (-0.9999) ** -5 # doctest: +SKIP
-1.000500150035007 -1.000500150035007
>>> 1.0001 ** -6 >>> 1.0001 ** -6 # doctest: +SKIP
0.99940020994401269 0.99940020994401269
>>> 0.9999 ** -6 >>> 0.9999 ** -6 # doctest: +SKIP
1.0006002100560125 1.0006002100560125
>>> (-1.0001) ** -6 >>> (-1.0001) ** -6 # doctest: +SKIP
0.99940020994401269 0.99940020994401269
>>> (-0.9999) ** -6 >>> (-0.9999) ** -6 # doctest: +SKIP
1.0006002100560125 1.0006002100560125
etc. etc.
We run the tests with values a very small epsilon away from 1: We run the tests with values a very small epsilon away from 1:
small enough that the result is indistinguishable from 1 when small enough that the result is indistinguishable from 1 when
rounded to nearest at the output precision. We check that the rounded to nearest at the output precision. We check that the
result is not erroneously rounded to 1 in cases where the result is not erroneously rounded to 1 in cases where the
rounding should be done strictly away from 1. rounding should be done strictly away from 1.
""" """
 End of changes. 8 change blocks. 
8 lines changed or deleted 8 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS