diff options
author | Edoardo Pasca <edo.paskino@gmail.com> | 2017-08-23 12:56:09 +0100 |
---|---|---|
committer | Edoardo Pasca <edo.paskino@gmail.com> | 2017-10-11 15:48:33 +0100 |
commit | 48a4d5315b4b6ca62eaa931912b6a02993979688 (patch) | |
tree | 00f548fe035ed355af585bb06e6d9545341f329f /src/Python/test.py | |
parent | bc29e0690d856ad9dd147b435d34c5761556a1e5 (diff) | |
download | regularization-48a4d5315b4b6ca62eaa931912b6a02993979688.tar.gz regularization-48a4d5315b4b6ca62eaa931912b6a02993979688.tar.bz2 regularization-48a4d5315b4b6ca62eaa931912b6a02993979688.tar.xz regularization-48a4d5315b4b6ca62eaa931912b6a02993979688.zip |
Test module for Boost Python
currently can pass a function to the C++ layer to be evaluated.
Diffstat (limited to 'src/Python/test.py')
-rw-r--r-- | src/Python/test.py | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/Python/test.py b/src/Python/test.py index e283f89..db47380 100644 --- a/src/Python/test.py +++ b/src/Python/test.py @@ -5,14 +5,38 @@ Created on Thu Aug 3 14:08:09 2017 @author: ofn77899 """ -import fista +import prova import numpy as np -a = np.asarray([i for i in range(3*4*5)]) -a = a.reshape([3,4,5]) +a = np.asarray([i for i in range(1*2*3)]) +a = a.reshape([1,2,3]) print (a) -b = fista.mexFunction(a) +b = prova.mexFunction(a) #print (b) print (b[4].shape) print (b[4]) -print (b[5])
\ No newline at end of file +print (b[5]) + +def print_element(input): + print ("f: {0}".format(input)) + +prova.doSomething(a, print_element, None) + +c = [] +def append_to_list(input, shouldPrint=False): + c.append(input) + if shouldPrint: + print ("{0} appended to list {1}".format(input, c)) + +def element_wise_algebra(input, shouldPrint=True): + ret = input - 7 + if shouldPrint: + print ("element_wise {0}".format(ret)) + return ret + +prova.doSomething(a, append_to_list, None) +#print ("this is c: {0}".format(c)) + +b = prova.doSomething(a, None, element_wise_algebra) +#print (a) +print (b[5]) |