Disabled external gits
This commit is contained in:
5316 files changed
+4563444
-6
No files matched your search
@@ -0,0 +1,116 @@
|
||||
import time
|
||||
import pytest
|
||||
import json
|
||||
import sys
|
||||
import igl
|
||||
import numpy as np
|
||||
sys.path.append('../')
|
||||
sys.path.append('../src')
|
||||
from elasticsolid import *
|
||||
from eigendecomposition_metric import *
|
||||
eps = 1E-6
|
||||
|
||||
with open('test_data1.json', 'r') as infile:
|
||||
homework_datas = json.load(infile)
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
@pytest.mark.parametrize("data", homework_datas[0])
|
||||
def test_rest_barycenters(data):
|
||||
v, t, rest_barycenters_gt = data
|
||||
es = ElasticSolid(np.array(v), np.array(t))
|
||||
es.make_rest_barycenters()
|
||||
rest_barycenters_student = es.rest_barycenters
|
||||
if(len(v) > 5000):
|
||||
return
|
||||
assert np.linalg.norm(rest_barycenters_gt - rest_barycenters_student) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
@pytest.mark.parametrize("data", homework_datas[1])
|
||||
def test_rest_shape_matrices(data):
|
||||
v, t, Dm_gt, Bm_gt = data
|
||||
es = ElasticSolid(np.array(v), np.array(t))
|
||||
es.make_rest_shape_matrices()
|
||||
Dm, Bm = es.Dm, es.Bm
|
||||
if(len(v) > 5000):
|
||||
return
|
||||
assert np.linalg.norm(Dm - Dm_gt) < eps
|
||||
assert np.linalg.norm(Bm - Bm_gt) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
@pytest.mark.parametrize("data", homework_datas[2])
|
||||
def test_def_barycenters(data):
|
||||
v, t, v_def, def_barycenters_gt = data
|
||||
es = ElasticSolid(np.array(v), np.array(t))
|
||||
es.v_def = np.array(v_def)
|
||||
es.make_def_barycenters()
|
||||
def_barycenters_student = es.def_barycenters
|
||||
if(len(v) > 5000):
|
||||
return
|
||||
assert np.linalg.norm(def_barycenters_gt - def_barycenters_student ) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
@pytest.mark.parametrize("data", homework_datas[3])
|
||||
def test_def_shape_matrices(data):
|
||||
v, t, v_def, Ds_gt = data
|
||||
es = ElasticSolid(np.array(v), np.array(t))
|
||||
es.v_def = np.array(v_def)
|
||||
es.make_def_shape_matrices()
|
||||
Ds = es.Ds
|
||||
if(len(v) > 5000):
|
||||
return
|
||||
assert np.linalg.norm(Ds - Ds_gt) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
@pytest.mark.parametrize("data", homework_datas[4])
|
||||
def test_update_rest_shape(data):
|
||||
v, t, v_update, rest_barycenters_gt, W0_gt, F_gt = data
|
||||
es = ElasticSolid(np.array(v), np.array(t))
|
||||
es.update_rest_shape(np.array(v_update))
|
||||
if(len(v) > 5000):
|
||||
return
|
||||
assert np.linalg.norm(es.rest_barycenters - rest_barycenters_gt) < eps
|
||||
assert np.linalg.norm(es.W0 - W0_gt) < eps
|
||||
assert np.linalg.norm(es.F - F_gt) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
@pytest.mark.parametrize("data", homework_datas[5])
|
||||
def test_update_def_shape(data):
|
||||
v, t, v_def, def_barycenters_gt, W_gt, F_gt = data
|
||||
es = ElasticSolid(np.array(v), np.array(t))
|
||||
es.update_def_shape(np.array(v_def))
|
||||
if(len(v) > 5000):
|
||||
return
|
||||
assert np.linalg.norm(es.def_barycenters - def_barycenters_gt) < eps
|
||||
assert np.linalg.norm(es.W - W_gt) < eps
|
||||
assert np.linalg.norm(es.F - F_gt) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
@pytest.mark.parametrize("data", homework_datas[6])
|
||||
def test_jacobians(data):
|
||||
v, t, v_def, Ds_gt, Bm_gt, F_gt = data
|
||||
es = ElasticSolid(np.array(v), np.array(t))
|
||||
es.v_def, es.Ds, es.Bm = np.array(v_def), np.array(Ds_gt), np.array(Bm_gt)
|
||||
es.make_jacobians()
|
||||
if(len(v) > 5000):
|
||||
return
|
||||
assert np.linalg.norm(es.F - F_gt) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
@pytest.mark.parametrize("data", homework_datas[7])
|
||||
def test_pinning(data):
|
||||
v, t, pin_idx, free_idx_gt, pin_mask_gt = data
|
||||
es = ElasticSolid(np.array(v), np.array(t), pin_idx = np.array(pin_idx))
|
||||
if(len(v) > 5000):
|
||||
return
|
||||
assert np.linalg.norm(es.free_idx - free_idx_gt) < eps
|
||||
assert np.linalg.norm(es.pin_mask.astype(float) - np.array(pin_mask_gt).astype(float)) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
@pytest.mark.parametrize("data", homework_datas[8])
|
||||
def test_eig(data):
|
||||
F, eigvals_gt, eigvecs_gt = data
|
||||
eigvals, eigvecs = compute_eigendecomposition_metric(np.array(F))
|
||||
if(len(F) > 5000):
|
||||
return
|
||||
assert np.linalg.norm(eigvals - eigvals_gt) < eps
|
||||
assert np.linalg.norm(abs(np.diagonal(np.einsum('ijk, ijl -> ikl', eigvecs, eigvecs_gt), axis1 = 1, axis2 = 2)) - 1) < eps
|
||||
@@ -0,0 +1 @@
|
||||
[[[[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], [[0, 1, 2, 3]], [[0.25, 0.25, 0.25]]], [[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [0.6666666666666666, 0.6666666666666666, 0.6666666666666666]], [[0, 1, 2, 3], [1, 2, 3, 4]], [[0.25, 0.25, 0.25], [0.41666666666666663, 0.41666666666666663, 0.41666666666666663]]], [[[-0.5144189453125, -0.006796875, 0.342559991040513], [-0.4533251953125, 0.477265625, 0.0], [-0.16156494140625, 0.48864501953125, 0.247196960449218], [0.0, 0.0, 0.0]], [[0, 1, 2, 3]], [[-0.2823272705078125, 0.2397784423828125, 0.14743923787243274]]], [[[1.92892740885417, 0.795891927083333, 7.06959962671885], [1.38140950520833, 1.12016276041667, 6.56891766057302], [1.77776204427083, 1.23249348958333, 6.5171683929949], [3.36708333333333, 1.2026953125, 6.34609376734385], [3.6378271484375, 0.736062825520833, 6.5233158539324], [2.94625162760417, 0.811892903645833, 6.42714804794282], [1.21115234375, 3.2785107421875, 4.03569032496105], [1.21115234375, 3.05222330729167, 4.03569032496105], [1.41037272135417, 3.22219563802083, 3.96712851669282], [1.17717610677083, 3.2785107421875, 3.7849456960548], [1.17717610677083, 3.05222330729167, 3.7849456960548], [0.826608072916667, 3.297607421875, 3.81374004826833], [0.906559244791667, 3.06875651041667, 4.0594486664324], [-0.165138346354167, 3.06035970052083, 4.22297080184907], [0.207609049479167, 2.72546223958333, 4.4538354665626], [0.426946614583333, 3.14258951822917, 4.07493613388032], [0.136866861979167, 3.15456380208333, 3.56399293726573], [-0.284313151041667, 2.76587565104167, 3.67290386662772], [0.477122395833333, 2.6718603515625, 4.01503704533865], [0.0884342447916667, 2.43097819010417, 3.90376873479177], [0.1993896484375, 2.6778466796875, 3.48202435002615], [0.114910481770833, 2.01370768229167, 3.82798341578135], [-0.3699169921875, 2.3461474609375, 3.66176983342458], [0.826608072916667, 2.83990559895833, 3.81374004826833], [0.746658528645833, 3.06875651041667, 3.56803143010427], [1.07312174479167, 0.186591796875, 3.35497946884125], [0.9015087890625, 0.186591796875, 3.12470684514333], [1.20571940104167, 0.2429052734375, 3.13923911239593], [1.07312174479167, 0.412877604166667, 3.35497946884125], [0.806204427083333, 0.396344401041667, 3.63202109481782], [0.616028645833333, 0.167493489583333, 3.41086997177093], [0.3102978515625, 0.322511393229167, 3.97484458114593], [-0.206339518229167, 0.720045572916667, 5.0712231618751], [-0.866873372395833, 0.563816731770833, 4.36135377710948], [-0.273390299479167, 0.4047412109375, 4.2340454275001], [0.155592447916667, 0.739638671875, 4.44255210067718], [-0.394640299479167, 1.118955078125, 3.66679506128917], [0.114910481770833, 1.45139322916667, 3.82798341578135], [-0.0198177083333333, 1.03412272135417, 3.91484336044282], [-1.1627880859375, 0.668907877604167, 3.70662782496105], [-0.448800455729167, 0.699225260416667, 3.70633628036468], [-1.65739908854167, 0.4868603515625, 4.67379762476573], [0.616028645833333, 0.625196940104167, 3.41086997177093], [0.9015087890625, 0.412877604166667, 3.12470684514333], [0.4258544921875, 0.396344401041667, 3.18971905217458], [-1.25579336387079, 2.94434041341147, 0.247196960449218], [-1.54755361777704, 2.95571980794272, 0.0], [-1.09422964316767, 3.46414021809897, 0.0], [-1.25579336387079, 3.9889766438802, 0.247196960449218], [-1.60864858848017, 3.4709395345052, 0.342559991040513], [-1.54755361777704, 3.97978230794272, 0.0], [-2.42104549153645, 3.65468636067708, 2.9570504222104], [-1.66876912434895, 3.16619026692708, 2.68253211166352], [-1.72982670124777, 3.68813736979167, 1.90246897460907], [-3.33207438151042, 3.12324055989583, 3.52005433863292], [-2.04028645833333, 3.24179850260417, 4.17553794052093], [-2.82052490234375, 2.88153157552083, 4.66295208440115], [-2.6843221842448, 3.65153190104167, 1.9230649218747], [-3.01930135091147, 3.05401643880208, 2.43617029525727], [-1.9243285201208, 4.16030232747395, 0.0], [-3.1018050733139, 3.70525227864583, 0.0], [-2.17311557100355, 3.8179404296875, 0.524649200439453], [-1.9243285201208, 2.78452596028645, 0.0], [-2.17311557100355, 3.10023990885417, 0.524649200439453], [-3.1018050733139, 3.19518880208333, 0.0], [-2.24000845176142, 3.47388875325522, 0.0], [-3.21087890625, 2.32591145833333, 2.55441530054698], [-4.38078694661458, 2.22052734375, 3.06782899683605], [-2.6704286295573, 2.86222135416667, 1.78254087402313], [-2.26702498372397, 2.56552034505208, 2.1616521067807], [-2.89291433115097, 3.38942643229167, 0.981263467152913], [-1.65064127604167, 2.49373697916667, 2.88164450790375], [-1.67526810749777, 2.98055729166667, 1.68948270751923], [-2.42513210458847, 3.02414518229167, 1.00103408177694], [-1.95734987802597, 3.44676822916667, 1.02080471165975], [-2.42513210458847, 3.81204947916667, 1.00103408177694], [2.92133138020833, 0.893297526041667, 8.61891277776052], [3.2291259765625, 1.302109375, 8.75000083114593], [2.63646647135417, 1.34214680989583, 8.80626547958343], [4.520048828125, 0.773118489583333, 6.2334Line truncated
|
||||
Reference in new issue
Block a user