in tutorials/LinearAlgebra/testing.py [0:0]
def inner_prod_test(fun):
for i in range(10):
v = gen_complex_matrix(w = 1)
w = gen_complex_matrix(len(v), 1)
expected = inner_prod_ref(v, w)
actual = fun(v, w)
if type(actual) == list:
print("You should return a number, not a matrix")
return
if actual == None or actual == ...:
print("Your function must return a value!")
return
if actual != approx(expected):
print("Unexpected result of inner product:\n"
+ gen_labeled_message([v, w], ["V: ", "W: "])
+ "Expected: {0:.3f}\n\n".format(expected)
+ "You returned: {0:.3f}\n\nTry again!".format(actual))
return
print("Success!")