##// END OF EJS Templates
Switched to CMake, added a basic python test (with ctypes), simplified kcoef init function
Switched to CMake, added a basic python test (with ctypes), simplified kcoef init function

File last commit:

r23:2e08872d5b98 tip TCH
r23:2e08872d5b98 tip TCH
Show More
init_k_coefficients.py
27 lines | 999 B | text/x-python | PythonLexer
/ tests / init_k_coefficients.py
from ctypes import *
import numpy as np
import os
import sys
import unittest
class init_k_coefficients(unittest.TestCase):
def setUp(self):
self.lib_basic_params = cdll.LoadLibrary(f'{os.path.dirname(os.path.realpath(__file__))}/../../build-LFR_basic-parameters-Desktop-Default/liblfr_basic_params.so')
def tearDown(self):
pass
def test_init_k_coefficients_f0(self):
nb_bins = 11
nb_binscompressed_matrix = c_char(nb_bins)
k_coefficients = (c_float * (32 * nb_bins))()
for i in range(len(k_coefficients)):
k_coefficients[i] = 100.*np.random.random()
self.lib_basic_params.init_k_coefficients(k_coefficients, nb_binscompressed_matrix)
self.assertTrue(all([ v==1. if i not in ( 2, 3, 34, 35, 66, 67, 98, 99, 130, 131, 162, 163, 194, 195, 226, 227, 258, 259, 290, 291, 322, 323) else v==0. for i,v in enumerate(k_coefficients) ]))
if __name__ == '__main__':
unittest.main()