Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 48678a84 authored by hhakim's avatar hhakim
Browse files

Slightly modify unit tests for norm(), __getitem__() and test params (num. of...

Slightly modify unit tests for norm(), __getitem__() and test params (num. of factors and dimension sizes).
parent 9edf6d71
Branches
Tags
No related merge requests found
...@@ -11,8 +11,8 @@ import math ...@@ -11,8 +11,8 @@ import math
class TestFaustPy(unittest.TestCase): class TestFaustPy(unittest.TestCase):
MAX_NUM_FACTORS = 64 # for the tested Faust MAX_NUM_FACTORS = 32 # for the tested Faust
MAX_DIM_SIZE = 1000 MAX_DIM_SIZE = 512
def setUp(self): def setUp(self):
""" Initializes the tests objects """ """ Initializes the tests objects """
...@@ -77,7 +77,7 @@ class TestFaustPy(unittest.TestCase): ...@@ -77,7 +77,7 @@ class TestFaustPy(unittest.TestCase):
def testNorm2(self): def testNorm2(self):
print("testNorm2()") print("testNorm2()")
ref_norm = norm(self.F.todense()) ref_norm = norm(self.mulFactors())
test_norm = self.F.norm(2) test_norm = self.F.norm(2)
# print("ref_norm=", ref_norm, "test_norm=", test_norm) # print("ref_norm=", ref_norm, "test_norm=", test_norm)
# TODO: remove this workaround when the supposed bug will be corrected in core lib # TODO: remove this workaround when the supposed bug will be corrected in core lib
...@@ -126,9 +126,12 @@ class TestFaustPy(unittest.TestCase): ...@@ -126,9 +126,12 @@ class TestFaustPy(unittest.TestCase):
def testGetItem(self): def testGetItem(self):
print("testGetItem()") print("testGetItem()")
n = self.factors[0].shape[0] n = self.factors[0].shape[0]
# test whole array
prod = self.mulFactors() prod = self.mulFactors()
test_prod = self.F[::,::] test_prod = self.F[::,::]
self.assertProdEq(prod, test_prod) self.assertProdEq(prod, test_prod)
test_prod = self.F[...,...]
self.assertProdEq(prod, test_prod)
# test one random element # test one random element
rand_i, rand_j = self.r.randint(0,self.F.get_nb_rows()-1),self.r.randint(0,self.F.get_nb_cols()-1) rand_i, rand_j = self.r.randint(0,self.F.get_nb_rows()-1),self.r.randint(0,self.F.get_nb_cols()-1)
if(prod[rand_i,rand_j] != 0): if(prod[rand_i,rand_j] != 0):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment