mirror of
https://github.com/micropython/micropython.git
synced 2026-01-10 05:57:16 +01:00
all: Update Python formatting to latest Black version 22.1.0.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -27,15 +27,15 @@ print(1j * 2j)
|
||||
print(1j / 2)
|
||||
print((1j / 2j).real)
|
||||
print(1j / (1 + 2j))
|
||||
ans = 0j ** 0
|
||||
ans = 0j**0
|
||||
print("%.5g %.5g" % (ans.real, ans.imag))
|
||||
ans = 0j ** 1
|
||||
ans = 0j**1
|
||||
print("%.5g %.5g" % (ans.real, ans.imag))
|
||||
ans = 0j ** 0j
|
||||
ans = 0j**0j
|
||||
print("%.5g %.5g" % (ans.real, ans.imag))
|
||||
ans = 1j ** 2.5
|
||||
ans = 1j**2.5
|
||||
print("%.5g %.5g" % (ans.real, ans.imag))
|
||||
ans = 1j ** 2.5j
|
||||
ans = 1j**2.5j
|
||||
print("%.5g %.5g" % (ans.real, ans.imag))
|
||||
|
||||
# comparison
|
||||
@@ -116,10 +116,10 @@ except ZeroDivisionError:
|
||||
|
||||
# zero division via power
|
||||
try:
|
||||
0j ** -1
|
||||
0j**-1
|
||||
except ZeroDivisionError:
|
||||
print("ZeroDivisionError")
|
||||
try:
|
||||
0j ** 1j
|
||||
0j**1j
|
||||
except ZeroDivisionError:
|
||||
print("ZeroDivisionError")
|
||||
|
||||
@@ -88,7 +88,7 @@ except ZeroDivisionError:
|
||||
print("ZeroDivisionError")
|
||||
|
||||
try:
|
||||
0.0 ** -1
|
||||
0.0**-1
|
||||
except ZeroDivisionError:
|
||||
print("ZeroDivisionError")
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ if ll_type != 0:
|
||||
print(int(1418774543.0))
|
||||
print("%d" % 1418774543.0)
|
||||
if ll_type == 3:
|
||||
print(int(2.0 ** 100))
|
||||
print("%d" % 2.0 ** 100)
|
||||
print(int(2.0**100))
|
||||
print("%d" % 2.0**100)
|
||||
else:
|
||||
print(int(1073741823.0))
|
||||
print("%d" % 1073741823.0)
|
||||
@@ -44,7 +44,7 @@ else:
|
||||
testpass = True
|
||||
p2_rng = ((30, 63, 1024), (62, 63, 1024))[is_64bit][ll_type]
|
||||
for i in range(0, p2_rng):
|
||||
bitcnt = len(bin(int(2.0 ** i))) - 3
|
||||
bitcnt = len(bin(int(2.0**i))) - 3
|
||||
if i != bitcnt:
|
||||
print("fail: 2**%u was %u bits long" % (i, bitcnt))
|
||||
testpass = False
|
||||
@@ -53,7 +53,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed"))
|
||||
testpass = True
|
||||
p10_rng = ((9, 18, 23), (18, 18, 23))[is_64bit][ll_type]
|
||||
for i in range(0, p10_rng):
|
||||
digcnt = len(str(int(10.0 ** i))) - 1
|
||||
digcnt = len(str(int(10.0**i))) - 1
|
||||
if i != digcnt:
|
||||
print("fail: 10**%u was %u digits long" % (i, digcnt))
|
||||
testpass = False
|
||||
@@ -72,28 +72,28 @@ def fp2int_test(num, name, should_fail):
|
||||
if ll_type != 2:
|
||||
if ll_type == 0:
|
||||
if is_64bit:
|
||||
neg_bad_fp = -1.00000005 * 2.0 ** 62.0
|
||||
pos_bad_fp = 2.0 ** 62.0
|
||||
neg_good_fp = -(2.0 ** 62.0)
|
||||
pos_good_fp = 0.99999993 * 2.0 ** 62.0
|
||||
neg_bad_fp = -1.00000005 * 2.0**62.0
|
||||
pos_bad_fp = 2.0**62.0
|
||||
neg_good_fp = -(2.0**62.0)
|
||||
pos_good_fp = 0.99999993 * 2.0**62.0
|
||||
else:
|
||||
neg_bad_fp = -1.00000005 * 2.0 ** 30.0
|
||||
pos_bad_fp = 2.0 ** 30.0
|
||||
neg_good_fp = -(2.0 ** 30.0)
|
||||
pos_good_fp = 0.9999999499 * 2.0 ** 30.0
|
||||
neg_bad_fp = -1.00000005 * 2.0**30.0
|
||||
pos_bad_fp = 2.0**30.0
|
||||
neg_good_fp = -(2.0**30.0)
|
||||
pos_good_fp = 0.9999999499 * 2.0**30.0
|
||||
else:
|
||||
neg_bad_fp = -0.51 * 2.0 ** 64.0
|
||||
pos_bad_fp = 2.0 ** 63.0
|
||||
neg_good_fp = -(2.0 ** 63.0)
|
||||
pos_good_fp = 1.9999998 * 2.0 ** 62.0
|
||||
neg_bad_fp = -0.51 * 2.0**64.0
|
||||
pos_bad_fp = 2.0**63.0
|
||||
neg_good_fp = -(2.0**63.0)
|
||||
pos_good_fp = 1.9999998 * 2.0**62.0
|
||||
|
||||
fp2int_test(neg_bad_fp, "neg bad", True)
|
||||
fp2int_test(pos_bad_fp, "pos bad", True)
|
||||
fp2int_test(neg_good_fp, "neg good", False)
|
||||
fp2int_test(pos_good_fp, "pos good", False)
|
||||
else:
|
||||
fp2int_test(-1.9999999999999981 * 2.0 ** 1023.0, "large neg", False)
|
||||
fp2int_test(1.9999999999999981 * 2.0 ** 1023.0, "large pos", False)
|
||||
fp2int_test(-1.9999999999999981 * 2.0**1023.0, "large neg", False)
|
||||
fp2int_test(1.9999999999999981 * 2.0**1023.0, "large pos", False)
|
||||
|
||||
fp2int_test(float("inf"), "inf test", True)
|
||||
fp2int_test(float("-inf"), "inf test", True)
|
||||
|
||||
@@ -34,13 +34,13 @@ if ll_type is None:
|
||||
print(int(14187744.0))
|
||||
print("%d" % 14187744.0)
|
||||
if ll_type == 2:
|
||||
print(int(2.0 ** 100))
|
||||
print("%d" % 2.0 ** 100)
|
||||
print(int(2.0**100))
|
||||
print("%d" % 2.0**100)
|
||||
|
||||
testpass = True
|
||||
p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type]
|
||||
for i in range(0, p2_rng):
|
||||
bitcnt = len(bin(int(2.0 ** i))) - 3
|
||||
bitcnt = len(bin(int(2.0**i))) - 3
|
||||
if i != bitcnt:
|
||||
print("fail: 2.**%u was %u bits long" % (i, bitcnt))
|
||||
testpass = False
|
||||
@@ -50,7 +50,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed"))
|
||||
testpass = True
|
||||
p10_rng = 9
|
||||
for i in range(0, p10_rng):
|
||||
digcnt = len(str(int(10.0 ** i))) - 1
|
||||
digcnt = len(str(int(10.0**i))) - 1
|
||||
if i != digcnt:
|
||||
print("fail: 10.**%u was %u digits long" % (i, digcnt))
|
||||
testpass = False
|
||||
@@ -69,28 +69,28 @@ def fp2int_test(num, name, should_fail):
|
||||
if ll_type != 2:
|
||||
if ll_type == 0:
|
||||
if is_64bit:
|
||||
neg_bad_fp = -1.00000005 * 2.0 ** 62.0
|
||||
pos_bad_fp = 2.0 ** 62.0
|
||||
neg_good_fp = -(2.0 ** 62.0)
|
||||
pos_good_fp = 0.99999993 * 2.0 ** 62.0
|
||||
neg_bad_fp = -1.00000005 * 2.0**62.0
|
||||
pos_bad_fp = 2.0**62.0
|
||||
neg_good_fp = -(2.0**62.0)
|
||||
pos_good_fp = 0.99999993 * 2.0**62.0
|
||||
else:
|
||||
neg_bad_fp = -1.00000005 * 2.0 ** 30.0
|
||||
pos_bad_fp = 2.0 ** 30.0
|
||||
neg_good_fp = -(2.0 ** 30.0)
|
||||
pos_good_fp = 0.9999999499 * 2.0 ** 30.0
|
||||
neg_bad_fp = -1.00000005 * 2.0**30.0
|
||||
pos_bad_fp = 2.0**30.0
|
||||
neg_good_fp = -(2.0**30.0)
|
||||
pos_good_fp = 0.9999999499 * 2.0**30.0
|
||||
else:
|
||||
neg_bad_fp = -0.51 * 2.0 ** 64.0
|
||||
pos_bad_fp = 2.0 ** 63.0
|
||||
neg_good_fp = -(2.0 ** 63.0)
|
||||
pos_good_fp = 1.9999998 * 2.0 ** 62.0
|
||||
neg_bad_fp = -0.51 * 2.0**64.0
|
||||
pos_bad_fp = 2.0**63.0
|
||||
neg_good_fp = -(2.0**63.0)
|
||||
pos_good_fp = 1.9999998 * 2.0**62.0
|
||||
|
||||
fp2int_test(neg_bad_fp, "neg bad", True)
|
||||
fp2int_test(pos_bad_fp, "pos bad", True)
|
||||
fp2int_test(neg_good_fp, "neg good", False)
|
||||
fp2int_test(pos_good_fp, "pos good", False)
|
||||
else:
|
||||
fp2int_test(-1.999999879 * 2.0 ** 126.0, "large neg", False)
|
||||
fp2int_test(1.999999879 * 2.0 ** 126.0, "large pos", False)
|
||||
fp2int_test(-1.999999879 * 2.0**126.0, "large neg", False)
|
||||
fp2int_test(1.999999879 * 2.0**126.0, "large pos", False)
|
||||
|
||||
fp2int_test(float("inf"), "inf test", True)
|
||||
fp2int_test(float("-inf"), "inf test", True)
|
||||
|
||||
@@ -37,13 +37,13 @@ print(int(14187745.))
|
||||
print("%d" % 14187745.)
|
||||
# fmt: on
|
||||
if ll_type == 2:
|
||||
print(int(2.0 ** 100))
|
||||
print("%d" % 2.0 ** 100)
|
||||
print(int(2.0**100))
|
||||
print("%d" % 2.0**100)
|
||||
|
||||
testpass = True
|
||||
p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type]
|
||||
for i in range(0, p2_rng):
|
||||
bitcnt = len(bin(int(2.0 ** i))) - 3
|
||||
bitcnt = len(bin(int(2.0**i))) - 3
|
||||
if i != bitcnt:
|
||||
print("fail: 2.**%u was %u bits long" % (i, bitcnt))
|
||||
testpass = False
|
||||
@@ -53,7 +53,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed"))
|
||||
testpass = True
|
||||
p10_rng = 9 if (ll_type == 0 and ~is_64bit) else 11
|
||||
for i in range(0, p10_rng):
|
||||
digcnt = len(str(int(10.0 ** i))) - 1
|
||||
digcnt = len(str(int(10.0**i))) - 1
|
||||
if i != digcnt:
|
||||
print("fail: 10.**%u was %u digits long" % (i, digcnt))
|
||||
testpass = False
|
||||
@@ -72,28 +72,28 @@ def fp2int_test(num, name, should_fail):
|
||||
if ll_type != 2:
|
||||
if ll_type == 0:
|
||||
if is_64bit:
|
||||
neg_bad_fp = -1.00000005 * 2.0 ** 62.0
|
||||
pos_bad_fp = 2.0 ** 62.0
|
||||
neg_good_fp = -(2.0 ** 62.0)
|
||||
pos_good_fp = 0.99999993 * 2.0 ** 62.0
|
||||
neg_bad_fp = -1.00000005 * 2.0**62.0
|
||||
pos_bad_fp = 2.0**62.0
|
||||
neg_good_fp = -(2.0**62.0)
|
||||
pos_good_fp = 0.99999993 * 2.0**62.0
|
||||
else:
|
||||
neg_bad_fp = -1.00000005 * 2.0 ** 30.0
|
||||
pos_bad_fp = 2.0 ** 30.0
|
||||
neg_good_fp = -(2.0 ** 30.0)
|
||||
pos_good_fp = 0.9999999499 * 2.0 ** 30.0
|
||||
neg_bad_fp = -1.00000005 * 2.0**30.0
|
||||
pos_bad_fp = 2.0**30.0
|
||||
neg_good_fp = -(2.0**30.0)
|
||||
pos_good_fp = 0.9999999499 * 2.0**30.0
|
||||
else:
|
||||
neg_bad_fp = -0.51 * 2.0 ** 64.0
|
||||
pos_bad_fp = 2.0 ** 63.0
|
||||
neg_good_fp = -(2.0 ** 63.0)
|
||||
pos_good_fp = 1.9999998 * 2.0 ** 62.0
|
||||
neg_bad_fp = -0.51 * 2.0**64.0
|
||||
pos_bad_fp = 2.0**63.0
|
||||
neg_good_fp = -(2.0**63.0)
|
||||
pos_good_fp = 1.9999998 * 2.0**62.0
|
||||
|
||||
fp2int_test(neg_bad_fp, "neg bad", True)
|
||||
fp2int_test(pos_bad_fp, "pos bad", True)
|
||||
fp2int_test(neg_good_fp, "neg good", False)
|
||||
fp2int_test(pos_good_fp, "pos good", False)
|
||||
else:
|
||||
fp2int_test(-1.999999879 * 2.0 ** 127.0, "large neg", False)
|
||||
fp2int_test(1.999999879 * 2.0 ** 127.0, "large pos", False)
|
||||
fp2int_test(-1.999999879 * 2.0**127.0, "large neg", False)
|
||||
fp2int_test(1.999999879 * 2.0**127.0, "large pos", False)
|
||||
|
||||
fp2int_test(float("inf"), "inf test", True)
|
||||
fp2int_test(float("nan"), "NaN test", True)
|
||||
|
||||
@@ -14,7 +14,7 @@ for x in values:
|
||||
except ZeroDivisionError:
|
||||
print(" / ZeroDivisionError")
|
||||
try:
|
||||
print(" ** pow", x ** y, pow(x, y))
|
||||
print(" ** pow", x**y, pow(x, y))
|
||||
except ZeroDivisionError:
|
||||
print(" ** pow ZeroDivisionError")
|
||||
print(" == != < <= > >=", x == y, x != y, x < y, x <= y, x > y, x >= y)
|
||||
|
||||
@@ -19,7 +19,7 @@ print("%.5g" % (i / 1.2))
|
||||
print("%.5g" % (i * 1.2j).imag)
|
||||
|
||||
# negative power should produce float
|
||||
print("%.5g" % (i ** -1))
|
||||
print("%.5g" % (i**-1))
|
||||
print("%.5g" % ((2 + i - i) ** -3))
|
||||
|
||||
try:
|
||||
|
||||
@@ -4,6 +4,6 @@ except ZeroDivisionError:
|
||||
print("ZeroDivisionError")
|
||||
|
||||
try:
|
||||
0 ** -1
|
||||
0**-1
|
||||
except ZeroDivisionError:
|
||||
print("ZeroDivisionError")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# negative power should produce float
|
||||
|
||||
x = 2
|
||||
print(x ** -2)
|
||||
print(x**-2)
|
||||
|
||||
x = 3
|
||||
x **= -2
|
||||
|
||||
Reference in New Issue
Block a user