Merge pull request #1076 from corona10/complex_repr

Fix complex representation for negative imaginary number case.
This commit is contained in:
Aviv Palivoda authored and GitHub committed 2019-06-29 21:03:16 +03:00
commit 4bf317c3af
2 files changed
+7 -1

No files matched your search

+6
View File
@@ -135,3 +135,9 @@ msg = 'int too large to convert to float'
assert_raises(OverflowError, lambda: complex(10 ** 1000, 0), msg)
assert_raises(OverflowError, lambda: complex(0, 10 ** 1000), msg)
assert_raises(OverflowError, lambda: 0j + 10 ** 1000, msg)
# str/repr
assert '(1+1j)' == str(1+1j)
assert '(1-1j)' == str(1-1j)
assert '(1+1j)' == repr(1+1j)
assert '(1-1j)' == repr(1-1j)
+1 -1
View File
@@ -204,7 +204,7 @@ impl PyComplex {
if re == 0.0 {
format!("{}j", im)
} else {
format!("({}+{}j)", re, im)
format!("({}{:+}j)", re, im)
}
}