summaryrefslogtreecommitdiff
path: root/tests/float/complex1.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/float/complex1.py')
-rw-r--r--tests/float/complex1.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/tests/float/complex1.py b/tests/float/complex1.py
index c1fa61ba3..a510ffc83 100644
--- a/tests/float/complex1.py
+++ b/tests/float/complex1.py
@@ -27,11 +27,16 @@ print(1j * 2j)
print(1j / 2)
print((1j / 2j).real)
print(1j / (1 + 2j))
-ans = 0j ** 0; print("%.5g %.5g" % (ans.real, ans.imag))
-ans = 0j ** 1; print("%.5g %.5g" % (ans.real, ans.imag))
-ans = 0j ** 0j; print("%.5g %.5g" % (ans.real, ans.imag))
-ans = 1j ** 2.5; print("%.5g %.5g" % (ans.real, ans.imag))
-ans = 1j ** 2.5j; print("%.5g %.5g" % (ans.real, ans.imag))
+ans = 0j ** 0
+print("%.5g %.5g" % (ans.real, ans.imag))
+ans = 0j ** 1
+print("%.5g %.5g" % (ans.real, ans.imag))
+ans = 0j ** 0j
+print("%.5g %.5g" % (ans.real, ans.imag))
+ans = 1j ** 2.5
+print("%.5g %.5g" % (ans.real, ans.imag))
+ans = 1j ** 2.5j
+print("%.5g %.5g" % (ans.real, ans.imag))
# comparison
print(1j == 1)
@@ -40,7 +45,7 @@ print(0 + 0j == False, 1 + 0j == True)
print(False == 0 + 0j, True == 1 + 0j)
# comparison of nan is special
-nan = float('nan') * 1j
+nan = float("nan") * 1j
print(nan == 1j)
print(nan == nan)
@@ -56,20 +61,22 @@ print(type(hash(1j)))
print(1.2 + 3j)
# negative base and fractional power should create a complex
-ans = (-1) ** 2.3; print("%.5g %.5g" % (ans.real, ans.imag))
-ans = (-1.2) ** -3.4; print("%.5g %.5g" % (ans.real, ans.imag))
+ans = (-1) ** 2.3
+print("%.5g %.5g" % (ans.real, ans.imag))
+ans = (-1.2) ** -3.4
+print("%.5g %.5g" % (ans.real, ans.imag))
# check printing of inf/nan
-print(float('nan') * 1j)
-print(float('-nan') * 1j)
-print(float('inf') * (1 + 1j))
-print(float('-inf') * (1 + 1j))
+print(float("nan") * 1j)
+print(float("-nan") * 1j)
+print(float("inf") * (1 + 1j))
+print(float("-inf") * (1 + 1j))
# can't assign to attributes
try:
(1j).imag = 0
except AttributeError:
- print('AttributeError')
+ print("AttributeError")
# can't convert rhs to complex
try:
@@ -95,11 +102,11 @@ try:
except TypeError:
print("TypeError")
-#small int on LHS, complex on RHS, unsupported op
+# small int on LHS, complex on RHS, unsupported op
try:
print(1 | 1j)
except TypeError:
- print('TypeError')
+ print("TypeError")
# zero division
try: