in tutorials/ComplexArithmetic/testing.py [0:0]
def polar_mult_test(fun):
for i in range(25):
x = prep_random_polar()
y = prep_random_polar()
if i == 0:
x = (3, 2)
y = x
elif i == 1:
x = (3, -2)
y = x
expected = polar_mult_ref(x, y)
actual = fun(x, y)
msg = assert_tuple(actual)
if msg != None:
print(msg)
return
msg = assert_polar(expected, actual,
"Product doesn't seem to match expected value: expected ("
+ format_polar(x)
+ ") * ("
+ format_polar(y)
+ ") = "
+ format_polar(expected)
+ ", got "
+ format_polar(actual))
if msg != None:
print(msg)
return
print("Success!")