Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 885c9a75 authored by hhakim's avatar hhakim
Browse files

Fix testGetItem test that rarely failed.

The failure happens when F.shape[1] == 1 (F is generated randomly).

E
======================================================================
ERROR: testGetItem (__main__.TestFaustPy)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gitlab-runner/test_FaustPy.py", line 300, in testGetItem
    rand_i, rand_j = self.r.randint(0,self.F.shape[0]-2),self.r.randint(0,self.F.shape[1]-2)
  File "/usr/lib64/python3.9/random.py", line 338, in randint
    return self.randrange(a, b+1)
  File "/usr/lib64/python3.9/random.py", line 316, in randrange
    raise ValueError("empty range for randrange() (%d, %d, %d)" % (istart, istop, width))
parent 5503e831
Branches
Tags 3.38.15
No related merge requests found
Pipeline #834158 skipped
...@@ -24,10 +24,9 @@ class TestFaustPy(unittest.TestCase): ...@@ -24,10 +24,9 @@ class TestFaustPy(unittest.TestCase):
factors = [] factors = []
d2 = r.randint(TestFaustPy.MIN_DIM_SIZE, TestFaustPy.MAX_DIM_SIZE) d2 = r.randint(TestFaustPy.MIN_DIM_SIZE, TestFaustPy.MAX_DIM_SIZE)
for i in range(0, num_factors): for i in range(0, num_factors):
d1, d2 = d2, r.randint(1, TestFaustPy.MAX_DIM_SIZE) d1, d2 = d2, r.randint(TestFaustPy.MIN_DIM_SIZE, TestFaustPy.MAX_DIM_SIZE)
factors += [sparse.random(d1, d2, density=0.5, format='csr', factors += [sparse.random(d1, d2, density=0.5, format='csr',
dtype=np.float64)] #.toarray() removed dtype=np.float64)] #.toarray() removed
#print("factor",i,":", factors[i])
self.F = Faust(factors) self.F = Faust(factors)
self.factors = factors self.factors = factors
# we keep dense matrices as reference for the tests # we keep dense matrices as reference for the tests
...@@ -292,7 +291,7 @@ class TestFaustPy(unittest.TestCase): ...@@ -292,7 +291,7 @@ class TestFaustPy(unittest.TestCase):
prod = self.mulFactors() prod = self.mulFactors()
test_prod = self.F[::,::].toarray() test_prod = self.F[::,::].toarray()
self.assertProdEq(prod, test_prod) self.assertProdEq(prod, test_prod)
# reminder the Faust is of minimal size 3 for the both dims (MIN_DIM_SIZE) # remind the Faust is of minimal size 3 for the both dims (MIN_DIM_SIZE)
# test_prod = self.F[...,...].toarray() # forbidden (only one index can # test_prod = self.F[...,...].toarray() # forbidden (only one index can
# be an ellipsis) # be an ellipsis)
# self.assertProdEq(prod, test_prod) # self.assertProdEq(prod, test_prod)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment