diff --git a/Datasets/Cylindre/Cylindre_Delta 1,0_analyse brute.txt b/Datasets/Cylindre/Cylindre_Delta 1,0_analyse brute.txt index 5c14c5460df46d4e87efa762fe73fdd7761e0c6b..a19ee3e32ce5e38c5f21f546fbbceb594e4e18dd 100644 --- a/Datasets/Cylindre/Cylindre_Delta 1,0_analyse brute.txt +++ b/Datasets/Cylindre/Cylindre_Delta 1,0_analyse brute.txt @@ -1,4 +1,4 @@ -X (mm) Y (mm) Z (mm) téta (radian) rayon (mm) (xi-xmoy) (yi-ymoy) +X (mm) Y (mm) Z (mm) teta (radian) rayon (mm) (xi-xmoy) (yi-ymoy) -4,898874 34,334751 0,000000 -0,681820 30,756656 -19,383064 23,880300 -4,899164 34,141937 0,001082 -0,685797 30,607375 -19,383354 23,687486 -3,789294 35,196819 0,001400 -0,636133 30,758820 -18,273484 24,742368 diff --git a/Datasets/Cylindre/Cylindre_Delta 1,0_analyse rayon.txt b/Datasets/Cylindre/Cylindre_Delta 1,0_analyse rayon.txt index 89b39fea914ba8437269d4942f0f5fe00534635d..187e3348c0c8efa2a5f18c4f87c7931836963678 100644 --- a/Datasets/Cylindre/Cylindre_Delta 1,0_analyse rayon.txt +++ b/Datasets/Cylindre/Cylindre_Delta 1,0_analyse rayon.txt @@ -1,4 +1,4 @@ -Xmoy (mm) Ymoy (mm) Zmoy (mm) rayon moyen (mm) rayon écart type (mm) +Xmoy (mm) Ymoy (mm) Zmoy (mm) rayon moyen (mm) rayon ecart type (mm) 14,484190 10,454451 0,480723 21,971957 7,737398 15,253762 8,435195 1,492448 32,757553 1,243314 14,638315 9,688970 2,496679 32,908071 0,251908 diff --git a/Datasets/Echantillon/30-03-2023_Delta 1,0_analyse brute.txt b/Datasets/Echantillon/30-03-2023_Delta 1,0_analyse brute.txt index 3bfb9ada22aecaf8db6ecd3e0e2dc92fe176d30c..d278c8860d1bfa2305d6bbefc38b9f85d0428d75 100644 --- a/Datasets/Echantillon/30-03-2023_Delta 1,0_analyse brute.txt +++ b/Datasets/Echantillon/30-03-2023_Delta 1,0_analyse brute.txt @@ -1,4 +1,4 @@ -X (mm) Y (mm) Z (mm) téta (radian) rayon (mm) (xi-xmoy) (yi-ymoy) +X (mm) Y (mm) Z (mm) teta (radian) rayon (mm) (xi-xmoy) (yi-ymoy) 10,210823 7,103537 0,000000 -0,556636 1,448117 0,765088 -1,229506 10,184198 7,103548 0,000030 -0,540878 1,434219 0,738463 -1,229495 10,185973 7,121432 0,000572 -0,548435 1,419842 0,740238 -1,211611 diff --git a/Datasets/Echantillon/30-03-2023_Delta 1,0_analyse rayon.txt b/Datasets/Echantillon/30-03-2023_Delta 1,0_analyse rayon.txt index ef17d7079adbc6404db4b7ee770f9decb566acb0..a627a6a496fd12d8bbcb6328da370b3fa6c6c1de 100644 --- a/Datasets/Echantillon/30-03-2023_Delta 1,0_analyse rayon.txt +++ b/Datasets/Echantillon/30-03-2023_Delta 1,0_analyse rayon.txt @@ -1,4 +1,4 @@ -Xmoy (mm) Ymoy (mm) Zmoy (mm) rayon moyen (mm) rayon écart type (mm) +Xmoy (mm) Ymoy (mm) Zmoy (mm) rayon moyen (mm) rayon ecart type (mm) 9,445735 8,333043 0,520592 2,285259 0,887739 8,214791 10,014653 1,447270 3,078851 1,137282 8,364474 9,582373 2,514221 3,834010 0,231461 diff --git a/integration_tests/data_test.py b/integration_tests/data_test.py index 1bcafcb34fa9ede4ee23c42db4d3442410b0d9a9..ef2889d362a8d9a2cc0d736c2c7677989a737c8d 100644 --- a/integration_tests/data_test.py +++ b/integration_tests/data_test.py @@ -6,6 +6,7 @@ def check_discrete_data(expected_file, actual_file, ndigits=7,eps=0.00001) : minimal_output_data = "" output_data = "" expected = [] + x,y,z,r,std = 0,0,0,0,0 with open(expected_file, "r") as f: expected = f.readlines()[1:] expected = [line.replace(',','.').split('\t') for line in expected] @@ -21,6 +22,13 @@ def check_discrete_data(expected_file, actual_file, ndigits=7,eps=0.00001) : z_diff = round(abs(expected[i][2] - actual[i][2]),ndigits) r_diff = round(abs(expected[i][3] - actual[i][3]),ndigits) std_diff = round(abs(expected[i][4] - actual[i][4]),ndigits) + + x += x_diff + y += y_diff + z += z_diff + r += r_diff + std += std_diff + line = f"{str(i).rjust(4)}:\t X: {str(x_diff).rjust(8)}\t Y: {str(y_diff).rjust(8)}\t Z: {str(z_diff).rjust(8)}\t R: {str(r_diff).rjust(8)}\t STD: {str(std_diff).rjust(8)}" output_data += line + "\n" if x_diff > eps or y_diff > eps or z_diff > eps or r_diff > eps or std_diff > eps: @@ -28,12 +36,30 @@ def check_discrete_data(expected_file, actual_file, ndigits=7,eps=0.00001) : output.save_output_file(output_file, output_data) output.save_output_file(minimal_output_file, minimal_output_data) + x = round(x/len(expected),ndigits) + y = round(y/len(expected),ndigits) + z = round(z/len(expected),ndigits) + r = round(r/len(expected),ndigits) + std = round(std/len(expected),ndigits) + print() + print("Analyse données discretisées:") + print(f"difference moyenne X: {x}") + print(f"difference moyenne Y: {y}") + print(f"difference moyenne Z: {z}") + print(f"difference moyenne R: {r}") + print(f"difference moyenne STD: {std}") + print(f"diff globale des fichiers: {(x+y+z+r+std)/5}") + print(f"Voir {output_file} pour plus de détails") + print(f"Voir {minimal_output_file} pour les différences significatives") + print("_"*80) + def check_raw_data(expected_file, actual_file, ndigits=7,eps=0.00001) : output_file = "check_raw_data_full.txt" minimal_output_file = "check_raw_data_minimal.txt" minimal_output_data = "" output_data = "" expected = [] + x,y,z,t,r,xmoy,ymoy = 0,0,0,0,0,0,0 with open(expected_file, "r") as f: expected = f.readlines()[1:] expected = [line.replace(',','.').split('\t') for line in expected] @@ -51,21 +77,51 @@ def check_raw_data(expected_file, actual_file, ndigits=7,eps=0.00001) : r_diff = round(abs(expected[i][4] - actual[i][4]),ndigits) xmoy_diff = round(abs(expected[i][5] - actual[i][5]),ndigits) ymoy_diff = round(abs(expected[i][6] - actual[i][6]),ndigits) + + x += x_diff + y += y_diff + z += z_diff + t += t_diff + r += r_diff + xmoy += xmoy_diff + ymoy += ymoy_diff + line = f"{str(i).rjust(4)}:\t X: {str(x_diff).rjust(8)}\t Y: {str(y_diff).rjust(8)}\t Z: {str(z_diff).rjust(8)}\t T: {str(t_diff).rjust(8)}\t R: {str(r_diff).rjust(8)}\t Xmoy: {str(xmoy_diff).rjust(8)}\t Ymoy: {str(ymoy_diff).rjust(8)}" output_data += line + "\n" if x_diff > eps: - minimal_output_data += f"{i} : {x_diff}\n" + minimal_output_data += f"{i} : X diff {x_diff}\n" if y_diff > eps: - minimal_output_data += f"{i} : {y_diff}\n" + minimal_output_data += f"{i} : Y diff {y_diff}\n" if z_diff > eps: - minimal_output_data += f"{i} : {z_diff}\n" + minimal_output_data += f"{i} : Z diff {z_diff}\n" if t_diff > eps: - minimal_output_data += f"{i} : {t_diff}\n" + minimal_output_data += f"{i} : teta diff{ t_diff}\n" if r_diff > eps: - minimal_output_data += f"{i} : {r_diff}\n" + minimal_output_data += f"{i} : R diff {r_diff}\n" if xmoy_diff > eps: - minimal_output_data += f"{i} : {xmoy_diff}\n" + minimal_output_data += f"{i} : Xi-Xmoy diff {xmoy_diff}\n" if ymoy_diff > eps: - minimal_output_data += f"{i} : {ymoy_diff}\n" + minimal_output_data += f"{i} : Yi-Ymoy diff{ymoy_diff}\n" output.save_output_file(output_file, output_data) output.save_output_file(minimal_output_file, minimal_output_data) + x = round(x/len(expected),ndigits) + y = round(y/len(expected),ndigits) + z = round(z/len(expected),ndigits) + t = round(t/len(expected),ndigits) + r = round(r/len(expected),ndigits) + xmoy = round(xmoy/len(expected),ndigits) + ymoy = round(ymoy/len(expected),ndigits) + + print() + print("Analyse données brutes :") + print(f"diff moyenne de x : {x}") + print(f"diff moyenne de y : {y}") + print(f"diff moyenne de z : {z}") + print(f"diff moyenne de t : {t}") + print(f"diff moyenne de r : {r}") + print(f"diff moyenne de xmoy : {xmoy}") + print(f"diff moyenne de ymoy : {ymoy}") + print(f"diff gloabale des fichiers : {(x+y+z+t+r+xmoy+ymoy)/7}") + print(f"Voir {output_file} pour plus de détails") + print(f"Voir {minimal_output_file} pour les différences significatives") + print("_"*80) diff --git a/test.py b/test.py new file mode 100644 index 0000000000000000000000000000000000000000..9c93d1bb85e58536601f2af80b4d8eb7e8ad4edf --- /dev/null +++ b/test.py @@ -0,0 +1,50 @@ +from main import get_raw_data, get_discrete_data +from utils.files.file_data import Object +from utils.files.output import save_output_file, format_data +from utils.files.parsers import parse_obj_file +from integration_tests import data_test +import time + +import os + +def test_get_raw_data(obj_path:Object,expected_file:str, ndigits:int = 6, eps:float = 0.0001): + """ + Test the get_raw_data function + """ + obj = parse_obj_file(obj_path,normalised='z') + + # Calculate raw data and save it in a file + now = time.time() + data = get_raw_data(obj, ndigits) + print() + print("Time to calculate raw data: ", time.time() - now) + save_output_file('tmp_analyse_brute.txt', format_data(data, '\t', ["X (en mm)", "Y (en mm)", "Z (en mm)", "teta (en rad)", "rayon (en mm)","Xi-Xmoy","Yi-Ymoy"] )) + data_test.check_raw_data(expected_file, 'tmp_analyse_brute.txt', ndigits, eps) + os.remove('tmp_analyse_brute.txt') + +def test_get_discrete_data(obj_path:Object,expected_file:str, ndigits:int = 6, eps:float = 0.0001): + """ + Test the get_discrete_data function + """ + obj = parse_obj_file(obj_path,normalised='z') + + # Calculate discrete data and save it in a file + now = time.time() + data = get_discrete_data(obj, ndigits) + print() + print("Time to calculate discrete data: ", time.time() - now) + save_output_file('tmp_analyse_discrete.txt', format_data(data, '\t', ["X moy (en mm)", "Y moy (en mm)", "Z moy (en mm)","Rayon moyen (en mm)","Rayon ecart type (en mm)"] )) + data_test.check_discrete_data(expected_file, 'tmp_analyse_discrete.txt', ndigits, eps) + os.remove('tmp_analyse_discrete.txt') + + +if __name__ == '__main__': + eps = 0.0001 + + #obj = ("datasets/Barette/3 - BARETTE v1.obj","datasets/Barette/BARETTE_Delta 1,0_analyse brute.txt","datasets/Barette/BARETTE_Delta 1,0_analyse rayon.txt") + obj = ("datasets/Cylindre/3 - CYLINDRE v1.obj","datasets/Cylindre/Cylindre_Delta 1,0_analyse brute.txt","datasets/Cylindre/Cylindre_Delta 1,0_analyse rayon.txt") + #obj = ("datasets/Echantillon/3 - KA50HN50_98% fusion v1.obj","datasets/Echantillon/30-03-2023_Delta 1,0_analyse brute.txt","datasets/Echantillon/30-03-2023_Delta 1,0_analyse rayon.txt") + + test_get_raw_data(obj[0],obj[1],eps=eps) + + test_get_discrete_data(obj[0],obj[2],eps=eps) \ No newline at end of file