Disabled external gits

This commit is contained in:
sora committed 2022-04-07 18:46:57 +02:00
1 parent 88cb3426ad
commit 15e7120d6d
5316 files changed
+4563444 -6

No files matched your search

+101
View File
@@ -0,0 +1,101 @@
import time
import pytest
import json
import sys
import igl
import numpy as np
sys.path.append('../')
sys.path.append('../src')
import json
from tracer_utils import intersection_event, find_edge_point,averaged_principal_curvatures, trace
from tracer_helper import Mesh
eps=1e-6
with open('test_data.json', 'r') as infile:
homework_data = json.load(infile)
@pytest.mark.timeout(0.5)
@pytest.mark.parametrize("data", homework_data[0])
def test_intersection_event(data):
ground_truth_t1, ground_truth_u1, ground_truth_E1, a1_orig, a1_dir, b1_orig, b1_dir, epsilon = data
a1_orig = np.array(a1_orig, dtype = float)
a1_dir = np.array(a1_dir, dtype = float)
b1_orig = np.array(b1_orig, dtype = float)
b1_dir = np.array(b1_dir, dtype = float)
student_t1, student_u1, student_E1 = intersection_event(a1_orig, a1_dir, b1_orig, b1_dir, epsilon)
if (ground_truth_t1 == None):
assert ground_truth_t1 == student_t1
assert ground_truth_u1 == student_u1
assert ground_truth_E1 == student_E1
else:
assert np.linalg.norm(ground_truth_t1 - student_t1) < eps
assert np.linalg.norm(ground_truth_u1 - student_u1) < eps
assert np.linalg.norm(ground_truth_E1 - student_E1) < eps
@pytest.mark.timeout(0.5)
def test_find_edge_point():
ground_truth_edge_point, ground_truth_is_boundary_point, v, f, a3_orig, a3_dir = homework_data[1]
ground_truth_edge_point = np.array(ground_truth_edge_point, dtype=float)
v = np.array(v, dtype=float)
f = np.array(f, dtype=int)
a3_orig = np.array(a3_orig, dtype=float)
a3_dir = np.array(a3_dir, dtype=float)
m = Mesh(v, f)
student_edge_point, student_is_boundary_point = find_edge_point(m, a3_orig, a3_dir)
assert np.linalg.norm(ground_truth_edge_point - student_edge_point) < eps
assert ground_truth_is_boundary_point == student_is_boundary_point
@pytest.mark.timeout(0.5)
def test_averaged_principal_curvatures():
ground_truth_k1,ground_truth_k2,ground_truth_v1,ground_truth_v2,ground_truth_n, a4_orig, v, f, num_neighbors, epsilon = homework_data[2]
ground_truth_k1 = np.array(ground_truth_k1, dtype=float)
ground_truth_k2 = np.array(ground_truth_k2, dtype=float)
ground_truth_v1 = np.array(ground_truth_v1, dtype=float)
ground_truth_v2 = np.array(ground_truth_v2, dtype=float)
ground_truth_n = np.array(ground_truth_n, dtype=float)
a4_orig = np.array(a4_orig, dtype=float)
v = np.array(v, dtype=float)
f = np.array(f, dtype=int)
m = Mesh(v, f)
student_k1,student_k2,student_v1,student_v2,student_n = averaged_principal_curvatures(a4_orig, m, num_neighbors, epsilon)
assert np.linalg.norm(ground_truth_k1 - student_k1) < eps
assert np.linalg.norm(ground_truth_k2 - student_k2) < eps
assert np.linalg.norm(ground_truth_v1 - student_v1) < eps
assert np.linalg.norm(ground_truth_v2 - student_v2) < eps
assert np.linalg.norm(ground_truth_n - student_n) < eps
@pytest.mark.timeout(0.5)
def test_trace_1():
ground_truth_P1, ground_truth_A1, ground_truth_PP1, vertex_idx, v, f, num_steps, epsilon, backward_trace, num_neighbors = homework_data[3]
ground_truth_P1 = np.array(ground_truth_P1, dtype=float)
ground_truth_A1 = np.array(ground_truth_A1, dtype=float)
ground_truth_PP1 = np.empty(ground_truth_PP1, dtype=float)
v = np.array(v, dtype=float)
f = np.array(f, dtype=int)
m = Mesh(v, f)
student_P1, student_A1, student_PP1 = trace(vertex_idx, m, num_steps, epsilon, True, backward_trace, num_neighbors)
assert np.linalg.norm(ground_truth_P1 - student_P1) < eps
assert np.linalg.norm(ground_truth_A1 - student_A1) < eps
assert np.linalg.norm(ground_truth_PP1 - student_PP1) < eps
@pytest.mark.timeout(0.5)
def test_trace_2():
ground_truth_P1, ground_truth_A1, ground_truth_PP1, vertex_idx, v, f, num_steps, epsilon, backward_trace, num_neighbors = homework_data[4]
ground_truth_P1 = np.array(ground_truth_P1, dtype=float)
ground_truth_A1 = np.array(ground_truth_A1, dtype=float)
ground_truth_PP1 = np.empty(ground_truth_PP1, dtype=float)
v = np.array(v, dtype=float)
f = np.array(f, dtype=int)
m = Mesh(v, f)
student_P1, student_A1, student_PP1 = trace(vertex_idx, m, num_steps, epsilon, False, backward_trace, num_neighbors)
assert np.linalg.norm(ground_truth_P1 - student_P1) < eps
assert np.linalg.norm(ground_truth_A1 - student_A1) < eps
assert np.linalg.norm(ground_truth_PP1 - student_PP1) < eps
@@ -0,0 +1 @@
[[[0.47057934424900016, 0.5094988870935965, 0, [-23.093492, -8.037475, 0.0], [28.741263, 30.437796, 0.0], [6.346344, -7.239107, 0.0], [-31.236165, 26.54575, 0.0], 1e-06], [null, null, 1, [-23.093492, -8.037475, 0.0], [31.236165, -26.54575, 0.0], [6.346344, -7.239107, 0.0], [-31.236165, 26.54575, 0.0], 1e-06]], [[6.945839826846992, -0.5696345351701145, 1.0086978183236321], false, [[6.964142322540283, -0.5750147104263306, 0.6868969202041626], [7.000217437744141, -0.6324173212051392, 1.0339537858963013], [6.784910370224459, -0.38383013010025024, 0.9339532852172852], [6.908111095428467, -0.2818911373615265, 0.6514014601707458], [6.927146911621094, -0.11774207651615143, 0.9152407050132751], [6.960897922515869, -0.44519713521003723, 1.2305725812911987], [6.9369916915893555, -0.20618999004364014, 1.1846444606781006]], [[1, 0, 2], [2, 0, 3], [2, 3, 4], [5, 1, 2], [2, 4, 6], [5, 2, 6]], [6.869522, -0.474084, 0.817323], [0.050116, -0.032483, 0.090725]], [1.9830129729572104, 3.778827309874611, [-0.8661568099862131, -0.029824907268628, 0.4988816046126825], [-0.07355351333822521, 0.981124844218919, -0.17884048963253682], [0.9304947753223014, 0.17060569781317753, 0.32414991743262667], [6.93535, -0.424391, 0.668657], [[6.964142322540283, -0.5750147104263306, 0.6868969202041626], [7.000217437744141, -0.6324173212051392, 1.0339537858963013], [6.784910370224459, -0.38383013010025024, 0.9339532852172852], [6.908111095428467, -0.2818911373615265, 0.6514014601707458], [6.927146911621094, -0.11774207651615143, 0.9152407050132751], [6.960897922515869, -0.44519713521003723, 1.2305725812911987], [6.9369916915893555, -0.20618999004364014, 1.1846444606781006]], [[1, 0, 2], [2, 0, 3], [2, 3, 4], [5, 1, 2], [2, 4, 6], [5, 2, 6]], 2, 1e-06], [[[6.873963832855225, -0.4367625117301941, 0.3892415761947632], [6.893680914347404, -0.2556819062447798, 0.5985632838980127], [6.903638551347885, -0.20915548053609734, 0.6485041925968332], [6.912270457902596, -0.06792925416026815, 0.8036046948568202], [6.9263747107468605, 0.02691673228261099, 0.9028006247475464], [6.927377040544729, 0.1068981736117228, 0.9845084546902056]], [0.7774365039764042, 0.7864940285783154, 0.7877465017357577, 0.7925078895904158, 0.800201918563536], [], 8, [[7.032979965209961, -0.8514668345451355, 0.6174484491348267], [6.964142322540283, -0.5750147104263306, 0.6868969202041626], [7.000217437744141, -0.6324173212051392, 1.0339537858963013], [6.952016353607178, -0.38383013010025024, 0.9339532852172852], [6.9258599281311035, 0.12335257232189178, 0.8945075273513794], [6.890464782714844, 0.005085608456283808, 0.6399703621864319], [7.037442684173584, -0.7946044206619263, 0.8785889744758606], [6.908111095428467, -0.2818911373615265, 0.6514014601707458], [6.873963832855225, -0.4367625117301941, 0.3892415761947632], [6.927146911621094, -0.11774207651615143, 0.9152407050132751], [6.914971351623535, -0.08622372150421143, 1.4240690469741821], [6.9308762550354, 0.06894616037607193, 1.1920952796936035], [6.960897922515869, -0.44519713521003723, 1.2305725812911987], [6.941605567932129, -0.712697446346283, 0.3753626346588135], [6.919645309448242, -0.2926464080810547, 1.490424633026123], [6.8338446617126465, -0.14700259268283844, 0.3794642686843872], [6.9369916915893555, -0.20618999004364014, 1.1846444606781006]], [[2, 1, 3], [3, 1, 7], [7, 1, 8], [3, 7, 9], [9, 4, 11], [5, 4, 9], [1, 0, 13], [8, 1, 13], [16, 11, 10], [14, 12, 16], [12, 2, 3], [3, 9, 16], [12, 3, 16], [11, 16, 9], [10, 14, 16], [5, 9, 7], [0, 1, 6], [1, 2, 6], [5, 7, 15], [8, 15, 7]], 20, 1e-06, false, 2], [[[6.873963832855225, -0.4367625117301941, 0.3892415761947632], [6.954706143919375, -0.6326627130666898, 0.5564569692859727], [7.004615552775657, -0.7375552919248757, 0.646064552184651], [7.034722553405902, -0.8292633814410305, 0.7194177643999167]], [0.7774365039764042, 0.7813828007772817, 0.7974029736629034], [], 8, [[7.032979965209961, -0.8514668345451355, 0.6174484491348267], [6.964142322540283, -0.5750147104263306, 0.6868969202041626], [7.000217437744141, -0.6324173212051392, 1.0339537858963013], [6.952016353607178, -0.38383013010025024, 0.9339532852172852], [6.9258599281311035, 0.12335257232189178, 0.8945075273513794], [6.890464782714844, 0.005085608456283808, 0.6399703621864319], [7.037442684173584, -0.7946044206619263, 0.8785889744758606], [6.908111095428467, -0.2818911373615265, 0.6514014601707458], [6.873963832855225, -0.4367625117301941, 0.3892415761947632], [6.927146911621094, -0.11774207651615143, 0.9152407050132751], [6.914971351623535, -0.08622372150421143, 1.4240690469741821], [6.9308762550354, 0.06894616037607193, 1.1920952796936035], [6.960897922515869, -0.44519713521003723, 1.2305725812911987], [6.941605567932129, -0.712697446346283, 0.3753626346588135], [6.919645309448242, -0.2926464080810547, 1.490424633026123], [6.8338446617126465, -0.14700259268283844, 0.3794642686843872], [6.9369916915893555, -0.20618999004364014, 1.1846444606781006]], [[2, 1, 3], [3, 1, 7], [7, 1, 8], [3, 7, 9], [9, 4, 11], [5, 4, 9Line truncated