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