Merge pull request #439 from skirpichev/fix-mpf-inf

Correct mpf initialization from tuple for f(n)inf
This commit is contained in:
Fredrik Johansson
2021-03-04 12:19:07 +01:00
committed by GitHub
2 changed files with 10 additions and 2 deletions
+4 -2
View File
@@ -67,9 +67,11 @@ class _mpf(mpnumeric):
v._mpf_ = from_man_exp(val[0], val[1], prec, rounding)
return v
if len(val) == 4:
sign, man, exp, bc = val
if val not in (finf, fninf, fnan):
sign, man, exp, bc = val
val = normalize(sign, MPZ(man), exp, bc, prec, rounding)
v = new(cls)
v._mpf_ = normalize(sign, MPZ(man), exp, bc, prec, rounding)
v._mpf_ = val
return v
raise ValueError
else:
+6
View File
@@ -443,3 +443,9 @@ def test_isnan_etc():
assert mp.isnpint(-1.1+0j) == False
assert mp.isnpint(-1+0.1j) == False
assert mp.isnpint(0+0.1j) == False
def test_issue_438():
assert mpf(finf) == mpf('inf')
assert mpf(fninf) == mpf('-inf')
assert mpf(fnan)._mpf_ == mpf('nan')._mpf_