Author: Brian Kearns <bdkea...@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): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit