summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_complex.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-05-29 22:18:09 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-05-29 22:18:09 (GMT)
commit0b76d3a8d1a3007d90f28763c5a907359d6ef538 (patch)
tree734a0486facc3801e28dc55149ce9ff09b1c49aa /Lib/test/test_complex.py
parent9a828d3c61a6df161b2aaf0a1309e26c9884fc59 (diff)
downloadcpython-0b76d3a8d1a3007d90f28763c5a907359d6ef538.zip
cpython-0b76d3a8d1a3007d90f28763c5a907359d6ef538.tar.gz
cpython-0b76d3a8d1a3007d90f28763c5a907359d6ef538.tar.bz2
This division test was too stringent in its accuracy expectations for
random inputs: if you ran the test 100 times, you could expect it to report a bogus failure. So loosened its expectations. Also changed the way failing tests are printed, so that when run under regrtest.py we get enough info to reproduce the failure.
Diffstat (limited to 'Lib/test/test_complex.py')
-rw-r--r--Lib/test/test_complex.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index ef44fbc..9faab71 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -5,7 +5,7 @@ from random import random
nerrors = 0
-def check_close_real(x, y, eps=1e-12):
+def check_close_real(x, y, eps=1e-9):
"""Return true iff floats x and y "are close\""""
# put the one with larger magnitude second
if abs(x) > abs(y):
@@ -17,7 +17,7 @@ def check_close_real(x, y, eps=1e-12):
# check that relative difference < eps
return abs((x-y)/y) < eps
-def check_close(x, y, eps=1e-12):
+def check_close(x, y, eps=1e-9):
"""Return true iff complexes x and y "are close\""""
return check_close_real(x.real, y.real, eps) and \
check_close_real(x.imag, y.imag, eps)
@@ -30,12 +30,12 @@ def test_div(x, y):
q = z / x
if not check_close(q, y):
nerrors += 1
- print `z`, "/", `x`, "==", `q`, "but expected", `y`
+ print "%r / %r == %r but expected %r" % (z, x, q, y)
if y != 0:
q = z / y
if not check_close(q, x):
nerrors += 1
- print `z`, "/", `y`, "==", `q`, "but expected", `x`
+ print "%r / %r == %r but expected %r" % (z, y, q, x)
simple_real = [float(i) for i in range(-5, 6)]
simple_complex = [complex(x, y) for x in simple_real for y in simple_real]