Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Lib/test/test_cmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ def test_constants(self):
self.assertAlmostEqual(cmath.e, e_expected, places=9,
msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_infinity_and_nan_constants(self):
self.assertEqual(cmath.inf.real, math.inf)
self.assertEqual(cmath.inf.imag, 0.0)
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,6 @@ def test_abs(self):
for num in nums:
self.assertAlmostEqual((num.real**2 + num.imag**2) ** 0.5, abs(num))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_repr_str(self):
def test(v, expected, test_fn=self.assertEqual):
test_fn(repr(v), expected)
Expand Down
7 changes: 5 additions & 2 deletions vm/src/builtins/complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,13 @@ impl PyComplex {
#[pymethod(magic)]
fn repr(&self) -> String {
let Complex64 { re, im } = self.value;
// converting to lowercase to format "NaN" as "nan"
if re == 0.0 {
format!("{}j", im)
format!("{}j", im).to_lowercase()
} else if im.is_nan() {
format!("({}+{:+}j)", re, im).to_lowercase()
} else {
format!("({}{:+}j)", re, im)
format!("({}{:+}j)", re, im).to_lowercase()
}
}

Expand Down