Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 244bdbab authored by hhakim's avatar hhakim
Browse files

Fix a bug and add related unit tests about slicing a Faust and then slicing again the sliced-Faust.

This bug was introduced by f1e59d07, hence 2.3rc3 wasn't touched.
parent 363e66a1
No related branches found
No related tags found
No related merge requests found
......@@ -198,11 +198,35 @@ classdef FaustTest < matlab.unittest.TestCase
col_i = randi([1,size(this.test_faust,2)]);
test_F = full(this.test_faust(:,col_i));
this.verifyEqual(test_F, ref_F(:,col_i), 'RelTol', 0.01)
% size(test_F)
% size(ref_F(:,col_i))
% size(ref_F)
% col_i
end
% test double-slice (on rows and cols at the same time)
tested_fausts = {this.test_faust, ctranspose(this.test_faust)}
for i=1,length(tested_fausts)
row_i1 = randi([1,size(tested_fausts{i},1)]);
row_i2 = randi([row_i1,size(tested_fausts{i},1)]);
col_i1 = randi([1,size(tested_fausts{i},2)]);
col_i2 = randi([col_i1,size(tested_fausts{i},2)]);
% slice test faust, affect the resulting Faust to G and compare the full matrices
full_test_F = full(tested_fausts{i});
G = tested_fausts{i}(row_i1:row_i2, col_i1:col_i2);
full_G = full(G);
this.verifyEqual(full_test_F(row_i1:row_i2, col_i1:col_i2),full_G,'RelTol', 0.0001)
% now slice G to get H
row_i1 = randi([1,size(G,1)]);
row_i2 = randi([row_i1,size(G,1)]);
col_i1 = randi([1,size(G,2)]);
col_i2 = randi([col_i1,size(G,2)]);
H = G(row_i1:row_i2, col_i1:col_i2);
full_H = full(H)
% ensure consistence of slicing on full matrices
this.verifyEqual(full_G(row_i1:row_i2, col_i1:col_i2), full_H, 'RelTol', 0.0001)
% test second slice on transpose of sliced Faust G
tG = transpose(G)
full_tG = full(tG)
I = tG(col_i1:col_i2, row_i1:row_i2)
full_I = full(I)
this.verifyEqual(full_I, full_tG(col_i1:col_i2, row_i1:row_i2), 'RelTol', 0.0001)
end
end
function testFull(this)
disp('Test Faust.full()')
......
......@@ -217,6 +217,17 @@ class TestFaustPy(unittest.TestCase):
sj2 = max(rand_j,rand_jj)
sF = self.F[si1:si2,sj1:sj2]
self.assertTrue((sF.todense() == self.F.todense()[si1:si2,sj1:sj2]).all())
# test a second slice on sF
rand_i, rand_j = self.r.randint(0,sF.shape[0]-1),self.r.randint(0,sF.shape[1]-1)
rand_ii, rand_jj = \
self.r.randint(rand_i+1,sF.shape[0]),self.r.randint(rand_j+1,sF.shape[1])
si1 = min(rand_i,rand_ii)
si2 = max(rand_i,rand_ii)
sj1 = min(rand_j,rand_jj)
sj2 = max(rand_j,rand_jj)
sF2 = sF[si1:si2,sj1:sj2]
self.assertTrue((sF2.todense() == sF.todense()[si1:si2,sj1:sj2]).all())
def testToDense(self):
print("testToDense()")
......
......@@ -201,16 +201,8 @@ namespace Faust {
this->is_conjugate = th->is_conjugate;
if(! (s[0].belong_to(0, th->getNbRow()) || s[1].belong_to(0, th->getNbCol())))
handleError("Faust::TransformHelper::TransformHelper(TransformHelper,Slice)", "Slice overflows a Faust dimension.");
if(th->is_sliced) { // slice of slice
this->slices[0].start_id = th->slices[0].start_id+s[0].start_id;
this->slices[0].end_id = th->slices[0].start_id+s[0].end_id;
this->slices[1].start_id = th->slices[1].start_id+s[1].start_id;
this->slices[1].end_id = th->slices[1].start_id+s[1].end_id;
}
else {
this->slices[0] = s[0];
this->slices[1] = s[1];
}
this->slices[0] = s[0];
this->slices[1] = s[1];
this->is_sliced = true;
this->transform = make_shared<Transform<FPP,Cpu>>(*eval_sliced_Transform());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment