summaryrefslogtreecommitdiff
path: root/tests/float/complex1.py
diff options
context:
space:
mode:
authorDavid Lechner <david@lechnology.com>2020-03-22 21:26:08 -0500
committerDamien George <damien.p.george@gmail.com>2020-03-30 13:21:58 +1100
commit3dc324d3f1312e40d3a8ed87e7244966bb756f26 (patch)
tree94ff44f8eabba0039582c245b901173597edd11e /tests/float/complex1.py
parent488613bca6c460340ed2995ae5cafafe22d0bfff (diff)
tests: Format all Python code with black, except tests in basics subdir.
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
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: