## "Fossies" - the Fresh Open Source Software Archive

### Source code changes of the file "mpmath/tests/test_hp.py" betweenmpmath-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_hp.py  (mpmath-1.0.0):test_hp.py  (mpmath-1.1.0)
skipping to change at line 222 skipping to change at line 222
m = 10 m = 10
r = r.replace(s[:-m],'') r = r.replace(s[:-m],'')
r = r.replace("mpf('",'').replace("')",'') r = r.replace("mpf('",'').replace("')",'')
num0 = 0 num0 = 0
for c in r: for c in r:
if c == '0': if c == '0':
num0 += 1 num0 += 1
else: else:
break break
b = float(int(r))/10**(len(r) - m) b = float(int(r))/10**(len(r) - m)
if b >= 10**m - 0.5: if b >= 10**m - 0.5: # pragma: no cover
raise NotImplementedError raise NotImplementedError
n = int(round(b)) n = int(round(b))
sn = str(n) sn = str(n)
s = s[:-m] + '0'*num0 + sn s = s[:-m] + '0'*num0 + sn
return s[-20:] return s[-20:]
# values checked with Mathematica # values checked with Mathematica
def test_log_hp(): def test_log_hp():
mp.dps = 2000 mp.dps = 2000
a = mpf(10)**15000/3 a = mpf(10)**15000/3
r = log(a) r = log(a)
res = last_digits(r) res = last_digits(r)
# Mathematica N[Log[10^15000/3], 2000] # Mathematica N[Log[10^15000/3], 2000]
# ...7443804441768333470331 # ...7443804441768333470331
assert res == '4' assert res == '43804441768333470331'
# see issue 145 # see issue 145
r = log(mpf(3)/2) r = log(mpf(3)/2)
# Mathematica N[Log[3/2], 2000] # Mathematica N[Log[3/2], 2000]
# ...69653749808140753263288 # ...69653749808140753263288
res = last_digits(r) res = last_digits(r)
assert res == '53749808140753263288' assert res == '53749808140753263288'
mp.dps = 10000 mp.dps = 10000
r = log(2) r = log(2)
res = last_digits(r) res = last_digits(r)
# Mathematica N[Log[2], 10000] # Mathematica N[Log[2], 10000]
# ...695615913401856601359655561 # ...695615913401856601359655561
assert res == '' assert res == '13401856601359655561'
r = log(mpf(10)**10/3) r = log(mpf(10)**10/3)
res = last_digits(r) res = last_digits(r)
# Mathematica N[Log[10^10/3], 10000] # Mathematica N[Log[10^10/3], 10000]
# ...587087654020631943060007154 # ...587087654020631943060007154
assert res == '54020631943060007154', res assert res == '54020631943060007154', res
r = log(mpf(10)**100/3) r = log(mpf(10)**100/3)
res = last_digits(r) res = last_digits(r)
# Mathematica N[Log[10^100/3], 10000] # Mathematica N[Log[10^100/3], 10000]
# ,,,59246336539088351652334666 # ,,,59246336539088351652334666
assert res == '36539088351652334666', res assert res == '36539088351652334666', res
End of changes. 3 change blocks.
3 lines changed or deleted 3 lines changed or added