Skip to content

Commit 8066f36

Browse files
authored
Fix copysign behavior for NaNs (RustPython#5396)
1 parent 3bbf6b9 commit 8066f36

File tree

4 files changed

+1
-11
lines changed

4 files changed

+1
-11
lines changed

Lib/test/test_complex.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,6 @@ class complex2(complex):
568568
self.assertFloatsAreIdentical(z.real, x)
569569
self.assertFloatsAreIdentical(z.imag, y)
570570

571-
# TODO: RUSTPYTHON
572-
@unittest.expectedFailure
573571
def test_constructor_negative_nans_from_string(self):
574572
self.assertEqual(copysign(1., complex("-nan").real), -1.)
575573
self.assertEqual(copysign(1., complex("-nanj").imag), -1.)

Lib/test/test_decimal.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,8 +2079,6 @@ def test_tonum_methods(self):
20792079
for d, n, r in test_triples:
20802080
self.assertEqual(str(round(Decimal(d), n)), r)
20812081

2082-
# TODO: RUSTPYTHON
2083-
@unittest.expectedFailure
20842082
def test_nan_to_float(self):
20852083
# Test conversions of decimal NANs to float.
20862084
# See http://bugs.python.org/issue15544

Lib/test/test_float.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,8 +1053,6 @@ def test_inf_signs(self):
10531053
self.assertEqual(copysign(1.0, float('inf')), 1.0)
10541054
self.assertEqual(copysign(1.0, float('-inf')), -1.0)
10551055

1056-
# TODO: RUSTPYTHON
1057-
@unittest.expectedFailure
10581056
@unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
10591057
"applies only when using short float repr style")
10601058
def test_nan_signs(self):

stdlib/src/math.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,7 @@ mod math {
110110

111111
#[pyfunction]
112112
fn copysign(x: ArgIntoFloat, y: ArgIntoFloat) -> f64 {
113-
if x.is_nan() || y.is_nan() {
114-
x.into()
115-
} else {
116-
x.copysign(*y)
117-
}
113+
x.copysign(*y)
118114
}
119115

120116
// Power and logarithmic functions:

0 commit comments

Comments
 (0)