Merge pull request #439 from skirpichev/fix-mpf-inf
Correct mpf initialization from tuple for f(n)inf
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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_
|
||||
|
||||
Reference in New Issue
Block a user