You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_task4_5.py 657 B

123456789101112131415161718192021
  1. from uctc.framework import basis
  2. import numpy as np
  3. import math
  4. import random
  5. def is_close(x, y):
  6. return abs(x - y) < 1e-5
  7. arr_a = [random.random() for i in range(128)]
  8. arr_b = [random.random() for i in range(128)]
  9. test_x = basis.addLists(arr_a, arr_b)
  10. test_y = [e1 + e2 for e1, e2 in zip(arr_a, arr_b)]
  11. for i, (x, y) in enumerate(zip(test_x, test_y)):
  12. if not is_close(x, y):
  13. print(f"\033[1;31mError: {basis.addLists.__name__} failed test at position {i}, expects {y} but gets {x}\033[0m")
  14. exit(0)
  15. print(f"\033[1;34mPassed: {basis.addLists.__name__} passed all tests\033[0m")
  16. print(f"\033[1;32m[PASSED] Task 4 finished!\033[0m")

计算机大作业

Contributors (1)