update to py tests and scripts due to black 22.1.0
This commit is contained in:
parent
a88969d306
commit
748834c6ba
@ -19,7 +19,7 @@ length = 8000 // 440
|
|||||||
# signed 16 bit
|
# signed 16 bit
|
||||||
s16 = array.array("h", [0] * length)
|
s16 = array.array("h", [0] * length)
|
||||||
for i in range(length):
|
for i in range(length):
|
||||||
s16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15))
|
s16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15))
|
||||||
print(s16[i])
|
print(s16[i])
|
||||||
|
|
||||||
sample = audiocore.RawSample(s16, sample_rate=8000)
|
sample = audiocore.RawSample(s16, sample_rate=8000)
|
||||||
|
@ -19,21 +19,21 @@ sample_names = ["unsigned 8 bit", "signed 8 bit", "unsigned 16 bit", "signed 16
|
|||||||
# unsigned 8 bit
|
# unsigned 8 bit
|
||||||
u8 = array.array("B", [0] * length)
|
u8 = array.array("B", [0] * length)
|
||||||
for i in range(length):
|
for i in range(length):
|
||||||
u8[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 7) + 2 ** 7)
|
u8[i] = int(math.sin(math.pi * 2 * i / length) * (2**7) + 2**7)
|
||||||
|
|
||||||
samples.append(audiocore.RawSample(u8, sample_rate=4000))
|
samples.append(audiocore.RawSample(u8, sample_rate=4000))
|
||||||
|
|
||||||
# signed 8 bit
|
# signed 8 bit
|
||||||
s8 = array.array("b", [0] * length)
|
s8 = array.array("b", [0] * length)
|
||||||
for i in range(length):
|
for i in range(length):
|
||||||
s8[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 7))
|
s8[i] = int(math.sin(math.pi * 2 * i / length) * (2**7))
|
||||||
|
|
||||||
samples.append(audiocore.RawSample(s8, sample_rate=16000))
|
samples.append(audiocore.RawSample(s8, sample_rate=16000))
|
||||||
|
|
||||||
# unsigned 16 bit
|
# unsigned 16 bit
|
||||||
u16 = array.array("H", [0] * length)
|
u16 = array.array("H", [0] * length)
|
||||||
for i in range(length):
|
for i in range(length):
|
||||||
u16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15) + 2 ** 15)
|
u16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15) + 2**15)
|
||||||
|
|
||||||
samples.append(audiocore.RawSample(u16, sample_rate=8000))
|
samples.append(audiocore.RawSample(u16, sample_rate=8000))
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ samples.append(audiocore.RawSample(u16, sample_rate=8000))
|
|||||||
# signed 16 bit
|
# signed 16 bit
|
||||||
s16 = array.array("h", [0] * length)
|
s16 = array.array("h", [0] * length)
|
||||||
for i in range(length):
|
for i in range(length):
|
||||||
s16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15))
|
s16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15))
|
||||||
|
|
||||||
samples.append(audiocore.RawSample(s16, sample_rate=8000))
|
samples.append(audiocore.RawSample(s16, sample_rate=8000))
|
||||||
|
|
||||||
|
@ -8,5 +8,5 @@ workaround: If you need integers larger than native wordsize use the random modu
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
x = random.randint(2 ** 128 - 1, 2 ** 128)
|
x = random.randint(2**128 - 1, 2**128)
|
||||||
print("x={}".format(x))
|
print("x={}".format(x))
|
||||||
|
@ -22,7 +22,7 @@ print(sha1.digest())
|
|||||||
|
|
||||||
sha1 = hashlib.sha1(b"hello")
|
sha1 = hashlib.sha1(b"hello")
|
||||||
try:
|
try:
|
||||||
sha1.update(u"world")
|
sha1.update("world")
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
print(sha1.digest())
|
print(sha1.digest())
|
||||||
|
@ -28,7 +28,7 @@ print(hashlib.sha256(b"\xff" * 56).digest())
|
|||||||
|
|
||||||
sha256 = hashlib.sha256(b"hello")
|
sha256 = hashlib.sha256(b"hello")
|
||||||
try:
|
try:
|
||||||
sha256.update(u"world")
|
sha256.update("world")
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
print(sha256.digest())
|
print(sha256.digest())
|
||||||
|
@ -27,15 +27,15 @@ print(1j * 2j)
|
|||||||
print(1j / 2)
|
print(1j / 2)
|
||||||
print((1j / 2j).real)
|
print((1j / 2j).real)
|
||||||
print(1j / (1 + 2j))
|
print(1j / (1 + 2j))
|
||||||
ans = 0j ** 0
|
ans = 0j**0
|
||||||
print("%.5g %.5g" % (ans.real, ans.imag))
|
print("%.5g %.5g" % (ans.real, ans.imag))
|
||||||
ans = 0j ** 1
|
ans = 0j**1
|
||||||
print("%.5g %.5g" % (ans.real, ans.imag))
|
print("%.5g %.5g" % (ans.real, ans.imag))
|
||||||
ans = 0j ** 0j
|
ans = 0j**0j
|
||||||
print("%.5g %.5g" % (ans.real, ans.imag))
|
print("%.5g %.5g" % (ans.real, ans.imag))
|
||||||
ans = 1j ** 2.5
|
ans = 1j**2.5
|
||||||
print("%.5g %.5g" % (ans.real, ans.imag))
|
print("%.5g %.5g" % (ans.real, ans.imag))
|
||||||
ans = 1j ** 2.5j
|
ans = 1j**2.5j
|
||||||
print("%.5g %.5g" % (ans.real, ans.imag))
|
print("%.5g %.5g" % (ans.real, ans.imag))
|
||||||
|
|
||||||
# comparison
|
# comparison
|
||||||
@ -116,10 +116,10 @@ except ZeroDivisionError:
|
|||||||
|
|
||||||
# zero division via power
|
# zero division via power
|
||||||
try:
|
try:
|
||||||
0j ** -1
|
0j**-1
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
print("ZeroDivisionError")
|
print("ZeroDivisionError")
|
||||||
try:
|
try:
|
||||||
0j ** 1j
|
0j**1j
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
print("ZeroDivisionError")
|
print("ZeroDivisionError")
|
||||||
|
@ -88,7 +88,7 @@ except ZeroDivisionError:
|
|||||||
print("ZeroDivisionError")
|
print("ZeroDivisionError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
0.0 ** -1
|
0.0**-1
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
print("ZeroDivisionError")
|
print("ZeroDivisionError")
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@ if ll_type != 0:
|
|||||||
print(int(1418774543.0))
|
print(int(1418774543.0))
|
||||||
print("%d" % 1418774543.0)
|
print("%d" % 1418774543.0)
|
||||||
if ll_type == 3:
|
if ll_type == 3:
|
||||||
print(int(2.0 ** 100))
|
print(int(2.0**100))
|
||||||
print("%d" % 2.0 ** 100)
|
print("%d" % 2.0**100)
|
||||||
else:
|
else:
|
||||||
print(int(1073741823.0))
|
print(int(1073741823.0))
|
||||||
print("%d" % 1073741823.0)
|
print("%d" % 1073741823.0)
|
||||||
@ -44,7 +44,7 @@ else:
|
|||||||
testpass = True
|
testpass = True
|
||||||
p2_rng = ((30, 63, 1024), (62, 63, 1024))[is_64bit][ll_type]
|
p2_rng = ((30, 63, 1024), (62, 63, 1024))[is_64bit][ll_type]
|
||||||
for i in range(0, p2_rng):
|
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:
|
if i != bitcnt:
|
||||||
print("fail: 2**%u was %u bits long" % (i, bitcnt))
|
print("fail: 2**%u was %u bits long" % (i, bitcnt))
|
||||||
testpass = False
|
testpass = False
|
||||||
@ -53,7 +53,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed"))
|
|||||||
testpass = True
|
testpass = True
|
||||||
p10_rng = ((9, 18, 23), (18, 18, 23))[is_64bit][ll_type]
|
p10_rng = ((9, 18, 23), (18, 18, 23))[is_64bit][ll_type]
|
||||||
for i in range(0, p10_rng):
|
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:
|
if i != digcnt:
|
||||||
print("fail: 10**%u was %u digits long" % (i, digcnt))
|
print("fail: 10**%u was %u digits long" % (i, digcnt))
|
||||||
testpass = False
|
testpass = False
|
||||||
@ -72,28 +72,28 @@ def fp2int_test(num, name, should_fail):
|
|||||||
if ll_type != 2:
|
if ll_type != 2:
|
||||||
if ll_type == 0:
|
if ll_type == 0:
|
||||||
if is_64bit:
|
if is_64bit:
|
||||||
neg_bad_fp = -1.00000005 * 2.0 ** 62.0
|
neg_bad_fp = -1.00000005 * 2.0**62.0
|
||||||
pos_bad_fp = 2.0 ** 62.0
|
pos_bad_fp = 2.0**62.0
|
||||||
neg_good_fp = -(2.0 ** 62.0)
|
neg_good_fp = -(2.0**62.0)
|
||||||
pos_good_fp = 0.99999993 * 2.0 ** 62.0
|
pos_good_fp = 0.99999993 * 2.0**62.0
|
||||||
else:
|
else:
|
||||||
neg_bad_fp = -1.00000005 * 2.0 ** 30.0
|
neg_bad_fp = -1.00000005 * 2.0**30.0
|
||||||
pos_bad_fp = 2.0 ** 30.0
|
pos_bad_fp = 2.0**30.0
|
||||||
neg_good_fp = -(2.0 ** 30.0)
|
neg_good_fp = -(2.0**30.0)
|
||||||
pos_good_fp = 0.9999999499 * 2.0 ** 30.0
|
pos_good_fp = 0.9999999499 * 2.0**30.0
|
||||||
else:
|
else:
|
||||||
neg_bad_fp = -0.51 * 2.0 ** 64.0
|
neg_bad_fp = -0.51 * 2.0**64.0
|
||||||
pos_bad_fp = 2.0 ** 63.0
|
pos_bad_fp = 2.0**63.0
|
||||||
neg_good_fp = -(2.0 ** 63.0)
|
neg_good_fp = -(2.0**63.0)
|
||||||
pos_good_fp = 1.9999998 * 2.0 ** 62.0
|
pos_good_fp = 1.9999998 * 2.0**62.0
|
||||||
|
|
||||||
fp2int_test(neg_bad_fp, "neg bad", True)
|
fp2int_test(neg_bad_fp, "neg bad", True)
|
||||||
fp2int_test(pos_bad_fp, "pos bad", True)
|
fp2int_test(pos_bad_fp, "pos bad", True)
|
||||||
fp2int_test(neg_good_fp, "neg good", False)
|
fp2int_test(neg_good_fp, "neg good", False)
|
||||||
fp2int_test(pos_good_fp, "pos good", False)
|
fp2int_test(pos_good_fp, "pos good", False)
|
||||||
else:
|
else:
|
||||||
fp2int_test(-1.9999999999999981 * 2.0 ** 1023.0, "large neg", 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(1.9999999999999981 * 2.0**1023.0, "large pos", False)
|
||||||
|
|
||||||
fp2int_test(float("inf"), "inf test", True)
|
fp2int_test(float("inf"), "inf test", True)
|
||||||
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(int(14187744.0))
|
||||||
print("%d" % 14187744.0)
|
print("%d" % 14187744.0)
|
||||||
if ll_type == 2:
|
if ll_type == 2:
|
||||||
print(int(2.0 ** 100))
|
print(int(2.0**100))
|
||||||
print("%d" % 2.0 ** 100)
|
print("%d" % 2.0**100)
|
||||||
|
|
||||||
testpass = True
|
testpass = True
|
||||||
p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type]
|
p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type]
|
||||||
for i in range(0, p2_rng):
|
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:
|
if i != bitcnt:
|
||||||
print("fail: 2.**%u was %u bits long" % (i, bitcnt))
|
print("fail: 2.**%u was %u bits long" % (i, bitcnt))
|
||||||
testpass = False
|
testpass = False
|
||||||
@ -50,7 +50,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed"))
|
|||||||
testpass = True
|
testpass = True
|
||||||
p10_rng = 9
|
p10_rng = 9
|
||||||
for i in range(0, p10_rng):
|
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:
|
if i != digcnt:
|
||||||
print("fail: 10.**%u was %u digits long" % (i, digcnt))
|
print("fail: 10.**%u was %u digits long" % (i, digcnt))
|
||||||
testpass = False
|
testpass = False
|
||||||
@ -69,28 +69,28 @@ def fp2int_test(num, name, should_fail):
|
|||||||
if ll_type != 2:
|
if ll_type != 2:
|
||||||
if ll_type == 0:
|
if ll_type == 0:
|
||||||
if is_64bit:
|
if is_64bit:
|
||||||
neg_bad_fp = -1.00000005 * 2.0 ** 62.0
|
neg_bad_fp = -1.00000005 * 2.0**62.0
|
||||||
pos_bad_fp = 2.0 ** 62.0
|
pos_bad_fp = 2.0**62.0
|
||||||
neg_good_fp = -(2.0 ** 62.0)
|
neg_good_fp = -(2.0**62.0)
|
||||||
pos_good_fp = 0.99999993 * 2.0 ** 62.0
|
pos_good_fp = 0.99999993 * 2.0**62.0
|
||||||
else:
|
else:
|
||||||
neg_bad_fp = -1.00000005 * 2.0 ** 30.0
|
neg_bad_fp = -1.00000005 * 2.0**30.0
|
||||||
pos_bad_fp = 2.0 ** 30.0
|
pos_bad_fp = 2.0**30.0
|
||||||
neg_good_fp = -(2.0 ** 30.0)
|
neg_good_fp = -(2.0**30.0)
|
||||||
pos_good_fp = 0.9999999499 * 2.0 ** 30.0
|
pos_good_fp = 0.9999999499 * 2.0**30.0
|
||||||
else:
|
else:
|
||||||
neg_bad_fp = -0.51 * 2.0 ** 64.0
|
neg_bad_fp = -0.51 * 2.0**64.0
|
||||||
pos_bad_fp = 2.0 ** 63.0
|
pos_bad_fp = 2.0**63.0
|
||||||
neg_good_fp = -(2.0 ** 63.0)
|
neg_good_fp = -(2.0**63.0)
|
||||||
pos_good_fp = 1.9999998 * 2.0 ** 62.0
|
pos_good_fp = 1.9999998 * 2.0**62.0
|
||||||
|
|
||||||
fp2int_test(neg_bad_fp, "neg bad", True)
|
fp2int_test(neg_bad_fp, "neg bad", True)
|
||||||
fp2int_test(pos_bad_fp, "pos bad", True)
|
fp2int_test(pos_bad_fp, "pos bad", True)
|
||||||
fp2int_test(neg_good_fp, "neg good", False)
|
fp2int_test(neg_good_fp, "neg good", False)
|
||||||
fp2int_test(pos_good_fp, "pos good", False)
|
fp2int_test(pos_good_fp, "pos good", False)
|
||||||
else:
|
else:
|
||||||
fp2int_test(-1.999999879 * 2.0 ** 126.0, "large neg", 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(1.999999879 * 2.0**126.0, "large pos", False)
|
||||||
|
|
||||||
fp2int_test(float("inf"), "inf test", True)
|
fp2int_test(float("inf"), "inf test", True)
|
||||||
fp2int_test(float("-inf"), "inf test", True)
|
fp2int_test(float("-inf"), "inf test", True)
|
||||||
|
@ -37,13 +37,13 @@ print(int(14187745.))
|
|||||||
print("%d" % 14187745.)
|
print("%d" % 14187745.)
|
||||||
# fmt: on
|
# fmt: on
|
||||||
if ll_type == 2:
|
if ll_type == 2:
|
||||||
print(int(2.0 ** 100))
|
print(int(2.0**100))
|
||||||
print("%d" % 2.0 ** 100)
|
print("%d" % 2.0**100)
|
||||||
|
|
||||||
testpass = True
|
testpass = True
|
||||||
p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type]
|
p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type]
|
||||||
for i in range(0, p2_rng):
|
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:
|
if i != bitcnt:
|
||||||
print("fail: 2.**%u was %u bits long" % (i, bitcnt))
|
print("fail: 2.**%u was %u bits long" % (i, bitcnt))
|
||||||
testpass = False
|
testpass = False
|
||||||
@ -53,7 +53,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed"))
|
|||||||
testpass = True
|
testpass = True
|
||||||
p10_rng = 9 if (ll_type == 0 and ~is_64bit) else 11
|
p10_rng = 9 if (ll_type == 0 and ~is_64bit) else 11
|
||||||
for i in range(0, p10_rng):
|
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:
|
if i != digcnt:
|
||||||
print("fail: 10.**%u was %u digits long" % (i, digcnt))
|
print("fail: 10.**%u was %u digits long" % (i, digcnt))
|
||||||
testpass = False
|
testpass = False
|
||||||
@ -72,28 +72,28 @@ def fp2int_test(num, name, should_fail):
|
|||||||
if ll_type != 2:
|
if ll_type != 2:
|
||||||
if ll_type == 0:
|
if ll_type == 0:
|
||||||
if is_64bit:
|
if is_64bit:
|
||||||
neg_bad_fp = -1.00000005 * 2.0 ** 62.0
|
neg_bad_fp = -1.00000005 * 2.0**62.0
|
||||||
pos_bad_fp = 2.0 ** 62.0
|
pos_bad_fp = 2.0**62.0
|
||||||
neg_good_fp = -(2.0 ** 62.0)
|
neg_good_fp = -(2.0**62.0)
|
||||||
pos_good_fp = 0.99999993 * 2.0 ** 62.0
|
pos_good_fp = 0.99999993 * 2.0**62.0
|
||||||
else:
|
else:
|
||||||
neg_bad_fp = -1.00000005 * 2.0 ** 30.0
|
neg_bad_fp = -1.00000005 * 2.0**30.0
|
||||||
pos_bad_fp = 2.0 ** 30.0
|
pos_bad_fp = 2.0**30.0
|
||||||
neg_good_fp = -(2.0 ** 30.0)
|
neg_good_fp = -(2.0**30.0)
|
||||||
pos_good_fp = 0.9999999499 * 2.0 ** 30.0
|
pos_good_fp = 0.9999999499 * 2.0**30.0
|
||||||
else:
|
else:
|
||||||
neg_bad_fp = -0.51 * 2.0 ** 64.0
|
neg_bad_fp = -0.51 * 2.0**64.0
|
||||||
pos_bad_fp = 2.0 ** 63.0
|
pos_bad_fp = 2.0**63.0
|
||||||
neg_good_fp = -(2.0 ** 63.0)
|
neg_good_fp = -(2.0**63.0)
|
||||||
pos_good_fp = 1.9999998 * 2.0 ** 62.0
|
pos_good_fp = 1.9999998 * 2.0**62.0
|
||||||
|
|
||||||
fp2int_test(neg_bad_fp, "neg bad", True)
|
fp2int_test(neg_bad_fp, "neg bad", True)
|
||||||
fp2int_test(pos_bad_fp, "pos bad", True)
|
fp2int_test(pos_bad_fp, "pos bad", True)
|
||||||
fp2int_test(neg_good_fp, "neg good", False)
|
fp2int_test(neg_good_fp, "neg good", False)
|
||||||
fp2int_test(pos_good_fp, "pos good", False)
|
fp2int_test(pos_good_fp, "pos good", False)
|
||||||
else:
|
else:
|
||||||
fp2int_test(-1.999999879 * 2.0 ** 127.0, "large neg", 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(1.999999879 * 2.0**127.0, "large pos", False)
|
||||||
|
|
||||||
fp2int_test(float("inf"), "inf test", True)
|
fp2int_test(float("inf"), "inf test", True)
|
||||||
fp2int_test(float("nan"), "NaN test", True)
|
fp2int_test(float("nan"), "NaN test", True)
|
||||||
|
@ -14,7 +14,7 @@ for x in values:
|
|||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
print(" / ZeroDivisionError")
|
print(" / ZeroDivisionError")
|
||||||
try:
|
try:
|
||||||
print(" ** pow", x ** y, pow(x, y))
|
print(" ** pow", x**y, pow(x, y))
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
print(" ** pow ZeroDivisionError")
|
print(" ** pow ZeroDivisionError")
|
||||||
print(" == != < <= > >=", x == y, x != y, x < y, x <= y, x > y, x >= y)
|
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)
|
print("%.5g" % (i * 1.2j).imag)
|
||||||
|
|
||||||
# negative power should produce float
|
# negative power should produce float
|
||||||
print("%.5g" % (i ** -1))
|
print("%.5g" % (i**-1))
|
||||||
print("%.5g" % ((2 + i - i) ** -3))
|
print("%.5g" % ((2 + i - i) ** -3))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -4,6 +4,6 @@ except ZeroDivisionError:
|
|||||||
print("ZeroDivisionError")
|
print("ZeroDivisionError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
0 ** -1
|
0**-1
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
print("ZeroDivisionError")
|
print("ZeroDivisionError")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# negative power should produce float
|
# negative power should produce float
|
||||||
|
|
||||||
x = 2
|
x = 2
|
||||||
print(x ** -2)
|
print(x**-2)
|
||||||
|
|
||||||
x = 3
|
x = 3
|
||||||
x **= -2
|
x **= -2
|
||||||
|
@ -11,7 +11,7 @@ except (ImportError, AttributeError):
|
|||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
if not (sys.platform == "linux" and sys.maxsize > 2 ** 32):
|
if not (sys.platform == "linux" and sys.maxsize > 2**32):
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ except (ImportError, AttributeError):
|
|||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
if not (sys.platform == "linux" and sys.maxsize > 2 ** 32):
|
if not (sys.platform == "linux" and sys.maxsize > 2**32):
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -52,12 +52,12 @@ class RungeKutta(object):
|
|||||||
# couplings are: g1, g2, g3 of U(1), SU(2), SU(3); yt (top Yukawa), lambda (Higgs quartic)
|
# couplings are: g1, g2, g3 of U(1), SU(2), SU(3); yt (top Yukawa), lambda (Higgs quartic)
|
||||||
# see arxiv.org/abs/0812.4950, eqs 10-15
|
# see arxiv.org/abs/0812.4950, eqs 10-15
|
||||||
sysSM = (
|
sysSM = (
|
||||||
lambda *a: 41.0 / 96.0 / math.pi ** 2 * a[1] ** 3, # g1
|
lambda *a: 41.0 / 96.0 / math.pi**2 * a[1] ** 3, # g1
|
||||||
lambda *a: -19.0 / 96.0 / math.pi ** 2 * a[2] ** 3, # g2
|
lambda *a: -19.0 / 96.0 / math.pi**2 * a[2] ** 3, # g2
|
||||||
lambda *a: -42.0 / 96.0 / math.pi ** 2 * a[3] ** 3, # g3
|
lambda *a: -42.0 / 96.0 / math.pi**2 * a[3] ** 3, # g3
|
||||||
lambda *a: 1.0
|
lambda *a: 1.0
|
||||||
/ 16.0
|
/ 16.0
|
||||||
/ math.pi ** 2
|
/ math.pi**2
|
||||||
* (
|
* (
|
||||||
9.0 / 2.0 * a[4] ** 3
|
9.0 / 2.0 * a[4] ** 3
|
||||||
- 8.0 * a[3] ** 2 * a[4]
|
- 8.0 * a[3] ** 2 * a[4]
|
||||||
@ -66,7 +66,7 @@ sysSM = (
|
|||||||
), # yt
|
), # yt
|
||||||
lambda *a: 1.0
|
lambda *a: 1.0
|
||||||
/ 16.0
|
/ 16.0
|
||||||
/ math.pi ** 2
|
/ math.pi**2
|
||||||
* (
|
* (
|
||||||
24.0 * a[5] ** 2
|
24.0 * a[5] ** 2
|
||||||
+ 12.0 * a[4] ** 2 * a[5]
|
+ 12.0 * a[4] ** 2 * a[5]
|
||||||
@ -137,5 +137,5 @@ def singleTraj(system, trajStart, h=0.02, tend=1.0):
|
|||||||
|
|
||||||
# initial conditions at M_Z
|
# initial conditions at M_Z
|
||||||
singleTraj(
|
singleTraj(
|
||||||
sysSM, [0.354, 0.654, 1.278, 0.983, 0.131], h=0.5, tend=math.log(10 ** 17)
|
sysSM, [0.354, 0.654, 1.278, 0.983, 0.131], h=0.5, tend=math.log(10**17)
|
||||||
) # true values
|
) # true values
|
||||||
|
@ -15,7 +15,7 @@ class GVector(object):
|
|||||||
self.z = z
|
self.z = z
|
||||||
|
|
||||||
def Mag(self):
|
def Mag(self):
|
||||||
return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)
|
return math.sqrt(self.x**2 + self.y**2 + self.z**2)
|
||||||
|
|
||||||
def dist(self, other):
|
def dist(self, other):
|
||||||
return math.sqrt(
|
return math.sqrt(
|
||||||
|
@ -22,7 +22,7 @@ class Vec:
|
|||||||
return Vec(self.x * rhs, self.y * rhs, self.z * rhs)
|
return Vec(self.x * rhs, self.y * rhs, self.z * rhs)
|
||||||
|
|
||||||
def length(self):
|
def length(self):
|
||||||
return (self.x ** 2 + self.y ** 2 + self.z ** 2) ** 0.5
|
return (self.x**2 + self.y**2 + self.z**2) ** 0.5
|
||||||
|
|
||||||
def normalise(self):
|
def normalise(self):
|
||||||
l = self.length()
|
l = self.length()
|
||||||
@ -87,12 +87,12 @@ class Sphere:
|
|||||||
def __init__(self, surface, centre, radius):
|
def __init__(self, surface, centre, radius):
|
||||||
self.surface = surface
|
self.surface = surface
|
||||||
self.centre = centre
|
self.centre = centre
|
||||||
self.radsq = radius ** 2
|
self.radsq = radius**2
|
||||||
|
|
||||||
def intersect(self, ray):
|
def intersect(self, ray):
|
||||||
v = self.centre - ray.p
|
v = self.centre - ray.p
|
||||||
b = v.dot(ray.d)
|
b = v.dot(ray.d)
|
||||||
det = b ** 2 - v.dot(v) + self.radsq
|
det = b**2 - v.dot(v) + self.radsq
|
||||||
if det > 0:
|
if det > 0:
|
||||||
det **= 0.5
|
det **= 0.5
|
||||||
t1 = b - det
|
t1 = b - det
|
||||||
@ -180,7 +180,7 @@ def trace_ray(scene, ray, depth):
|
|||||||
if ndotl > 0:
|
if ndotl > 0:
|
||||||
col += light_col * surf.diffuse * ndotl
|
col += light_col * surf.diffuse * ndotl
|
||||||
if ldotv > 0:
|
if ldotv > 0:
|
||||||
col += light_col * surf.specular * ldotv ** surf.spec_idx
|
col += light_col * surf.specular * ldotv**surf.spec_idx
|
||||||
|
|
||||||
# Reflections
|
# Reflections
|
||||||
if depth > 0 and surf.reflect > 0:
|
if depth > 0 and surf.reflect > 0:
|
||||||
|
@ -33,8 +33,8 @@ def compute_stats(lst):
|
|||||||
avg += x
|
avg += x
|
||||||
var += x * x
|
var += x * x
|
||||||
avg /= len(lst)
|
avg /= len(lst)
|
||||||
var = max(0, var / len(lst) - avg ** 2)
|
var = max(0, var / len(lst) - avg**2)
|
||||||
return avg, var ** 0.5
|
return avg, var**0.5
|
||||||
|
|
||||||
|
|
||||||
def run_script_on_target(target, script):
|
def run_script_on_target(target, script):
|
||||||
@ -201,7 +201,7 @@ def compute_diff(file1, file2, diff_score):
|
|||||||
sd1 *= av1 / 100 # convert from percent sd to absolute sd
|
sd1 *= av1 / 100 # convert from percent sd to absolute sd
|
||||||
sd2 *= av2 / 100 # convert from percent sd to absolute sd
|
sd2 *= av2 / 100 # convert from percent sd to absolute sd
|
||||||
av_diff = av2 - av1
|
av_diff = av2 - av1
|
||||||
sd_diff = (sd1 ** 2 + sd2 ** 2) ** 0.5
|
sd_diff = (sd1**2 + sd2**2) ** 0.5
|
||||||
percent = 100 * av_diff / av1
|
percent = 100 * av_diff / av1
|
||||||
percent_sd = 100 * sd_diff / av1
|
percent_sd = 100 * sd_diff / av1
|
||||||
print(
|
print(
|
||||||
|
@ -446,7 +446,7 @@ def do_all_the_things(elf_filename):
|
|||||||
if "size" not in symbol:
|
if "size" not in symbol:
|
||||||
print(symbol)
|
print(symbol)
|
||||||
size = symbol["size"] / 8
|
size = symbol["size"] / 8
|
||||||
square_size = size ** 0.5
|
square_size = size**0.5
|
||||||
if text_width_ish > square_size:
|
if text_width_ish > square_size:
|
||||||
w = text_width_ish
|
w = text_width_ish
|
||||||
h = size / text_width_ish
|
h = size / text_width_ish
|
||||||
|
Loading…
Reference in New Issue
Block a user