def test_gaussian_quadrature_matrix_algebra_weights(test_data): for N in test_data: if N >= 50: continue # Only works up to N = 40 G = GaussianQuadrature(N, method="matrix algebra") for wt, w in zip(G.w, test_data[N]["w"]): assert almost_equals(wt, w, eps=1e-2)
def test_e26_and_sumCl(): expected = [0, 0, 1.025704585, 0.3820158745, 0] l = [1,2,3,4,5] ad = 0.2 nd = 4 angles = [ [0, 1.9106, 1.9106, 1.9106], [1.9106, 0, 1.9106, 1.9106], [1.9106, 1.9106, 0, 1.9106], [1.9106, 1.9106, 1.9106, 0] ] wl0 = [e26(i, alpha(nd, ad)) for i in l] for i in range(len(l)): assert(almost_equals(sum_Cl(wl0[i], angles, nd, ad, l[i]), expected[i]))
def test_angles_fred(): vectors = [ [0, 0, 1], [-0.4714045208, -0.8164965809, -0.3333333333], [-0.4714045208, 0.8164965809, -0.3333333333], [0.9428090416, 0, -0.3333333333] ] angles = [ [0, 1.9106, 1.9106, 1.9106], [1.9106, 0, 1.9106, 1.9106], [1.9106, 1.9106, 0, 1.9106], [1.9106, 1.9106, 1.9106, 0] ] for i in range(len(vectors)): for j in range(len(vectors)): assert(almost_equals(angle_between(vectors[i], vectors[j]), angles[i][j], 0.0001))
def test_gen_angles(): vectors = [ [0, 0, 1], [-0.4714045208, -0.8164965809, -0.3333333333], [-0.4714045208, 0.8164965809, -0.3333333333], [0.9428090416, 0, -0.3333333333] ] expected = [ [0, 1.9106, 1.9106, 1.9106], [1.9106, 0, 1.9106, 1.9106], [1.9106, 1.9106, 0, 1.9106], [1.9106, 1.9106, 1.9106, 0] ] angles = generate_angles(vectors) for i in range(len(angles)): for j in range(len(angles)): assert(almost_equals(angles[i][j], expected[i][j]))
def test_angle_between_different_vectors(): v1 = [1,1,1] v2 = [1,1,2] assert(almost_equals(angle_between(v1, v2), 0.33984))
def test_angle_between_same_vector(): v1 = [1,1,1] v2 = [1,1,1] assert(almost_equals(angle_between(v1, v2), 0))
def is_finger_match(pair, finger_midi, files): """ does a collection pair match the level parameters? """ params = files.get_audio_params(pair[0]) return utils.almost_equals(params.finger_midi, finger_midi)
def is_level_match(pair, level_bbd, level_bv): """ does a collection pair match the level parameters? """ params = files.get_audio_params(pair[0]) return (utils.almost_equals(params.bow_bridge_distance, level_bbd) and utils.almost_equals(params.bow_velocity, level_bv))
def test_gaussian_quadrature_closed_form_weights(test_data): for N in test_data: G = GaussianQuadrature(N) for wt, w in zip(G.w, test_data[N]["w"]): assert almost_equals(wt, w)
def test_gaussian_quadrature_samples(test_data): for N in test_data: G = GaussianQuadrature(N) for xt, x in zip(G.x, test_data[N]["x"]): assert almost_equals(xt, x)