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

44 lines
1.7 KiB

  1. #!/usr/bin/env python
  2. from __future__ import print_function
  3. import sys
  4. sys.path.append('.')
  5. from example import fixed_r, fixed_c
  6. from example import fixed_passthrough_r, fixed_passthrough_c
  7. from example import dense_r, dense_c
  8. from example import dense_passthrough_r, dense_passthrough_c
  9. from example import sparse_r, sparse_c
  10. from example import sparse_passthrough_r, sparse_passthrough_c
  11. import numpy as np
  12. ref = np.array(
  13. [[0, 3, 0, 0, 0, 11],
  14. [22, 0, 0, 0, 17, 11],
  15. [7, 5, 0, 1, 0, 11],
  16. [0, 0, 0, 0, 0, 11],
  17. [0, 0, 14, 0, 8, 11]])
  18. def check(mat):
  19. return 'OK' if np.sum(mat - ref) == 0 else 'NOT OK'
  20. print("fixed_r = %s" % check(fixed_r()))
  21. print("fixed_c = %s" % check(fixed_c()))
  22. print("pt_r(fixed_r) = %s" % check(fixed_passthrough_r(fixed_r())))
  23. print("pt_c(fixed_c) = %s" % check(fixed_passthrough_c(fixed_c())))
  24. print("pt_r(fixed_c) = %s" % check(fixed_passthrough_r(fixed_c())))
  25. print("pt_c(fixed_r) = %s" % check(fixed_passthrough_c(fixed_r())))
  26. print("dense_r = %s" % check(dense_r()))
  27. print("dense_c = %s" % check(dense_c()))
  28. print("pt_r(dense_r) = %s" % check(dense_passthrough_r(dense_r())))
  29. print("pt_c(dense_c) = %s" % check(dense_passthrough_c(dense_c())))
  30. print("pt_r(dense_c) = %s" % check(dense_passthrough_r(dense_c())))
  31. print("pt_c(dense_r) = %s" % check(dense_passthrough_c(dense_r())))
  32. print("sparse_r = %s" % check(sparse_r()))
  33. print("sparse_c = %s" % check(sparse_c()))
  34. print("pt_r(sparse_r) = %s" % check(sparse_passthrough_r(sparse_r())))
  35. print("pt_c(sparse_c) = %s" % check(sparse_passthrough_c(sparse_c())))
  36. print("pt_r(sparse_c) = %s" % check(sparse_passthrough_r(sparse_c())))
  37. print("pt_c(sparse_r) = %s" % check(sparse_passthrough_c(sparse_r())))