From 51dc7b3f787906bb28b0fd4f71786f637e057287 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Tue, 5 Apr 2016 12:04:46 +0100 Subject: [PATCH 1/2] The default perturbation in the pair test is now 0. --- tests/testPair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testPair.c b/tests/testPair.c index 23ce4eb3d..6e46b577c 100644 --- a/tests/testPair.c +++ b/tests/testPair.c @@ -180,7 +180,7 @@ void runner_dopair1_density(struct runner *r, struct cell *ci, struct cell *cj); int main(int argc, char *argv[]) { size_t particles = 0, runs = 0, volume, type = 0; double offset[3] = {0, 0, 0}, h = 1.1255, size = 1., rho = 1.; - double perturbation = 0.1; + double perturbation = 0.; struct cell *ci, *cj; struct space space; struct engine engine; -- GitLab From 3b602c34c047b5f716214547b642d6284d603c7a Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Tue, 5 Apr 2016 12:23:36 +0100 Subject: [PATCH 2/2] The difffloat script now has an additional argument specifying how many lines (particles) to check. --- tests/difffloat.py | 25 ++++++++++++++++++++----- tests/test27cells.sh | 2 +- tests/test27cellsPerturbed.sh | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/tests/difffloat.py b/tests/difffloat.py index bbb7c95a1..d4b48d54c 100644 --- a/tests/difffloat.py +++ b/tests/difffloat.py @@ -28,12 +28,18 @@ rel_tol = 1e-7 # Comparisons are done both in absolute and relative terms # Individual tolerances for each column can be provided in a file +# The (cube root of) the number of lines to check is provided as +# an optional 4th argument file1 = sys.argv[1] file2 = sys.argv[2] -fileTol = "" +number_to_check = -1 + +if len(sys.argv) == 5: + number_to_check = int(sys.argv[4]) -if len(sys.argv) == 4: +fileTol = "" +if len(sys.argv) >= 4: fileTol = sys.argv[3] data1 = loadtxt(file1) @@ -67,8 +73,17 @@ else: absTol = dataTol[0,:] relTol = dataTol[1,:] +n_lines_to_check = 0 +if number_to_check > 0: + n_lines_to_check = number_to_check**3 + n_lines_to_check = min(n_lines_to_check, n_lines) + print "Checking the first %d particles."%n_lines_to_check +else: + n_lines_to_check = n_lines + print "Checking all particles in the file." + error = False -for i in range(n_lines): +for i in range(n_lines_to_check): for j in range(n_columns): abs_diff = abs(data1[i,j] - data2[i,j]) @@ -80,7 +95,7 @@ for i in range(n_lines): rel_diff = 0. if( abs_diff > absTol[j]): - print "Absolute difference larger than tolerance (%e) on line %d, column %d:"%(absTol[j], i,j) + print "Absolute difference larger than tolerance (%e) for particle %d, column %d:"%(absTol[j], i,j) print "%10s: a = %e"%("File 1", data1[i,j]) print "%10s: b = %e"%("File 2", data2[i,j]) print "%10s: |a-b| = %e"%("Difference", abs_diff) @@ -88,7 +103,7 @@ for i in range(n_lines): error = True if( rel_diff > relTol[j]): - print "Relative difference larger than tolerance (%e) on line %d, column %d:"%(relTol[j], i,j) + print "Relative difference larger than tolerance (%e) for particle %d, column %d:"%(relTol[j], i,j) print "%10s: a = %e"%("File 1", data1[i,j]) print "%10s: b = %e"%("File 2", data2[i,j]) print "%10s: |a-b|/|a+b| = %e"%("Difference", rel_diff) diff --git a/tests/test27cells.sh b/tests/test27cells.sh index 09d2513bd..0afdc32c9 100755 --- a/tests/test27cells.sh +++ b/tests/test27cells.sh @@ -3,6 +3,6 @@ rm brute_force_27_standard.dat swift_dopair_27_standard.dat ./test27cells -p 6 -r 1 -d 0 -f standard -python difffloat.py brute_force_27_standard.dat swift_dopair_27_standard.dat tolerance.dat +python difffloat.py brute_force_27_standard.dat swift_dopair_27_standard.dat tolerance.dat 6 exit $? diff --git a/tests/test27cellsPerturbed.sh b/tests/test27cellsPerturbed.sh index 73d293398..a553a2553 100755 --- a/tests/test27cellsPerturbed.sh +++ b/tests/test27cellsPerturbed.sh @@ -3,6 +3,6 @@ rm brute_force_27_perturbed.dat swift_dopair_27_perturbed.dat ./test27cells -p 6 -r 1 -d 0.1 -f perturbed -python difffloat.py brute_force_27_perturbed.dat swift_dopair_27_perturbed.dat tolerance.dat +python difffloat.py brute_force_27_perturbed.dat swift_dopair_27_perturbed.dat tolerance.dat 6 exit $? -- GitLab