[pypy-commit] pypy default: sign of nan can be ambiguous, use isnan
bdkearns
noreply at buildbot.pypy.org
Tue Nov 5 02:48:40 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r67841:b782ce0d380d
Date: 2013-11-04 20:46 -0500
http://bitbucket.org/pypy/pypy/changeset/b782ce0d380d/
Log: sign of nan can be ambiguous, use isnan
diff --git a/pypy/module/micronumpy/test/test_scalar.py b/pypy/module/micronumpy/test/test_scalar.py
--- a/pypy/module/micronumpy/test/test_scalar.py
+++ b/pypy/module/micronumpy/test/test_scalar.py
@@ -74,5 +74,6 @@
def test_complex_str_format(self):
import numpy as np
assert str(np.complex128(complex(1, float('nan')))) == '(1+nan*j)'
+ assert str(np.complex128(complex(1, float('-nan')))) == '(1+nan*j)'
assert str(np.complex128(complex(1, float('inf')))) == '(1+inf*j)'
assert str(np.complex128(complex(1, float('-inf')))) == '(1-inf*j)'
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -1034,7 +1034,7 @@
return imag_str
real_str = str_format(real)
- op = '+' if rfloat.copysign(1, imag) > 0 else ''
+ op = '+' if imag >= 0 or rfloat.isnan(imag) else ''
return ''.join(['(', real_str, op, imag_str, ')'])
def fill(self, storage, width, box, start, stop, offset):
More information about the pypy-commit
mailing list