50 lines
2.3 KiB
Python
50 lines
2.3 KiB
Python
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) |