Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-44698: Restore complex pow behaviour for small integral exponents #27772

Merged
Prev Previous commit
Next Next commit
Add regression test
  • Loading branch information
mdickinson committed Aug 15, 2021
commit 8895a6a357a987876daa19932b04c4076b7230b3
16 changes: 16 additions & 0 deletions Lib/test/test_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,22 @@ def test_pow(self):
except OverflowError:
pass

# Check that z**2.0 is handled identically to z**2.
values = [
complex(5.0, 12.0),
complex(5.0e100, 12.0e100),
complex(-4.0, INF),
complex(INF, 0.0),
]
for value in values:
with self.subTest(value=value):
int_square = value**2
float_square = value**2.0
self.assertFloatsAreIdentical(
int_square.real, float_square.real)
self.assertFloatsAreIdentical(
int_square.imag, float_square.imag)

def test_boolcontext(self):
for i in range(100):
self.assertTrue(complex(random() + 1e-6, random() + 1e-6))
Expand Down