"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mpmath/tests/test_elliptic.py" between
mpmath-1.0.0.tar.gz and mpmath-1.1.0.tar.gz

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

test_elliptic.py  (mpmath-1.0.0):test_elliptic.py  (mpmath-1.1.0)
skipping to change at line 18 skipping to change at line 18
[1] Abramowitz & Stegun. 'Handbook of Mathematical Functions, 9th Ed.', [1] Abramowitz & Stegun. 'Handbook of Mathematical Functions, 9th Ed.',
(Dover duplicate of 1972 edition) (Dover duplicate of 1972 edition)
[2] Whittaker 'A Course of Modern Analysis, 4th Ed.', 1946, [2] Whittaker 'A Course of Modern Analysis, 4th Ed.', 1946,
Cambridge University Press Cambridge University Press
""" """
import mpmath import mpmath
import random import random
import pytest
from mpmath import * from mpmath import *
def mpc_ae(a, b, eps=eps): def mpc_ae(a, b, eps=eps):
res = True res = True
res = res and a.real.ae(b.real, eps) res = res and a.real.ae(b.real, eps)
res = res and a.imag.ae(b.imag, eps) res = res and a.imag.ae(b.imag, eps)
return res return res
zero = mpf(0) zero = mpf(0)
skipping to change at line 115 skipping to change at line 116
def test_jtheta(): def test_jtheta():
mp.dps = 25 mp.dps = 25
z = q = zero z = q = zero
for n in range(1,5): for n in range(1,5):
value = jtheta(n, z, q) value = jtheta(n, z, q)
assert(value == (n-1)//2) assert(value == (n-1)//2)
for q in [one, mpf(2)]: for q in [one, mpf(2)]:
for n in range(1,5): for n in range(1,5):
raised = True pytest.raises(ValueError, lambda: jtheta(n, z, q))
try:
r = jtheta(n, z, q)
except:
pass
else:
raised = False
assert(raised)
z = one/10 z = one/10
q = one/11 q = one/11
# Mathematical N[EllipticTheta[1, 1/10, 1/11], 25] # Mathematical N[EllipticTheta[1, 1/10, 1/11], 25]
res = mpf('0.1069552990104042681962096') res = mpf('0.1069552990104042681962096')
result = jtheta(1, z, q) result = jtheta(1, z, q)
assert(result.ae(res)) assert(result.ae(res))
# Mathematica N[EllipticTheta[2, 1/10, 1/11], 25] # Mathematica N[EllipticTheta[2, 1/10, 1/11], 25]
skipping to change at line 178 skipping to change at line 172
# N[EllipticTheta[3, 1, 6/10 - 10^-6 - 8/10*I], 2000] # N[EllipticTheta[3, 1, 6/10 - 10^-6 - 8/10*I], 2000]
# then it works: # then it works:
# N[EllipticTheta[3, 1, 6/10 - 10^-6 - 8/10*I], 30] # N[EllipticTheta[3, 1, 6/10 - 10^-6 - 8/10*I], 30]
res = mpf('32.0031009628901652627099524264') + \ res = mpf('32.0031009628901652627099524264') + \
mpf('16.6153027998236087899308935624') * j mpf('16.6153027998236087899308935624') * j
result = jtheta(3, 1, q) result = jtheta(3, 1, q)
# check that for abs(q) > Q_LIM a ValueError exception is raised # check that for abs(q) > Q_LIM a ValueError exception is raised
mp.dps += 30 mp.dps += 30
q = mpf(6)/10 - one/10**7 - mpf(8)/10 * j q = mpf(6)/10 - one/10**7 - mpf(8)/10 * j
mp.dps -= 30 mp.dps -= 30
try: pytest.raises(ValueError, lambda: jtheta(3, 1, q))
result = jtheta(3, 1, q)
except ValueError:
pass
else:
assert(False)
# bug reported in issue 79 # bug reported in issue 79
mp.dps = 100 mp.dps = 100
z = (1+j)/3 z = (1+j)/3
q = mpf(368983957219251)/10**15 + mpf(636363636363636)/10**15 * j q = mpf(368983957219251)/10**15 + mpf(636363636363636)/10**15 * j
# Mathematica N[EllipticTheta[1, z, q], 35] # Mathematica N[EllipticTheta[1, z, q], 35]
res = mpf('2.4439389177990737589761828991467471') + \ res = mpf('2.4439389177990737589761828991467471') + \
mpf('0.5446453005688226915290954851851490') *j mpf('0.5446453005688226915290954851851490') *j
mp.dps = 30 mp.dps = 30
result = jtheta(1, z, q) result = jtheta(1, z, q)
 End of changes. 3 change blocks. 
14 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)