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_task3.py 573 B

1234567891011121314151617181920
  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 = [random.random() for i in range(128)]
  8. test_x = basis.negList(arr)
  9. test_y = [-e for e in arr]
  10. for i, (x, y) in enumerate(zip(test_x, test_y)):
  11. if not is_close(x, y):
  12. print(f"\033[1;31mError: {basis.negList.__name__} failed test at position {i}, expects {y} but gets {x}\033[0m")
  13. exit(0)
  14. print(f"\033[1;34mPassed: {basis.negList.__name__} passed all tests\033[0m")
  15. print(f"\033[1;32m[PASSED] Task 3 finished!\033[0m")

计算机大作业

Contributors (1)