Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 79dfc22d authored by hhakim's avatar hhakim
Browse files

Fix a bug: pyfaust.Faust.__getitem__() returns a Faust when indexing an element F[i,j].

- Modify getitem unit test in consequence.
It closes #33.
parent c408f913
No related branches found
No related tags found
No related merge requests found
......@@ -203,7 +203,7 @@ class TestFaustPy(unittest.TestCase):
# test one random element
rand_i, rand_j = self.r.randint(0,self.F.shape[0]-1),self.r.randint(0,self.F.shape[1]-1)
if(prod[rand_i,rand_j] != 0):
self.assertLessEqual(abs(self.F[rand_i,rand_j].todense()[0]-prod[rand_i,rand_j])/abs(prod[rand_i,rand_j]),
self.assertLessEqual(abs(self.F[rand_i,rand_j]-prod[rand_i,rand_j])/abs(prod[rand_i,rand_j]),
10**-6, msg=("compared values are (ref,rest) ="
+str(prod[rand_i,rand_j])+str(prod[rand_i,rand_j])))
# test one random row
......
......@@ -635,6 +635,8 @@ class Faust:
elif(isinstance(indices, tuple)):
if(len(indices) == 2):
out_indices = [0,0]
if(isinstance(indices[0], int) and isinstance(indices[1],int)):
return F.todense()[indices[0],indices[1]]
if(indices[0] == Ellipsis):
if(indices[1] == Ellipsis):
raise IndexError('an index can only have a single ellipsis '
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment