def test_dist_mat_to_vec_func_out_of_bounds(self, N, i, j): """Test that ValueError is raised when i or j or both are out of bounds of N""" # Check if i is out of bounds of N with pytest.raises(ValueError): PSA.dist_mat_to_vec(N, i, j)
def test_dist_mat_to_vec_func_i_equals_j(self): """Test that ValueError is raised when i == j or i,j == N""" with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, 4, 4) with self.assertRaises(ValueError): PSA.dist_mat_to_vec(4, 6, 4)
def test_dist_mat_to_vec_func_i_equals_j(self): """Test that ValueError is raised when i == j or i,j == N""" with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, 4, 4) with self.assertRaises(ValueError): PSA.dist_mat_to_vec(4, 6, 4)
def test_dist_mat_to_vec_func_bad_integers(self): """Test that ValueError is raised when i or j are not Integers""" with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, '6', '7') with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, float(6), 7)
def test_dist_mat_to_vec_func_bad_integers(self): """Test that ValueError is raised when i or j are not Integers""" with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, '6', '7') with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, float(6), 7)
def test_dist_mat_to_vec_func_bad_integers(self): """Test that ValueError is raised when i or j are not Integers""" with pytest.raises(ValueError) as err: PSA.dist_mat_to_vec(5, '6', '7') assert 'all must be of type int' in str(err.value) with pytest.raises(ValueError): PSA.dist_mat_to_vec(5, float(6), 7)
def test_distances_from_hausdorff_pairs_frames(self, psa): """Test whether actual distances between frames of Hausdorff pairs of a path give the expected Hausdorff distance""" psa.run_pairs_analysis(neighbors=True, hausdorff_pairs=True) hausd_pairs = psa.hausdorff_pairs npairs = int(psa.npaths * (psa.npaths - 1) / 2) hausd_pairs_dists2 = np.array([hausd_pairs[i]['distance'] for i in range(npairs)]) err_msg = ("A Hausdorff pair analysis distance when accessed " "by frame varies from expected Hausdorff distance") dists = np.zeros((psa.npaths, psa.npaths)) for i in range(0, psa.npaths-1): for j in range(i+1, psa.npaths): pairidx = PSA.dist_mat_to_vec(psa.npaths, i, j) p, q = hausd_pairs[pairidx]['frames'] dists[i,j] = (PSA.sqnorm(psa.paths[i][p,:,:] - psa.paths[j][q,:,:]) / psa.natoms)**0.5 assert_almost_equal(hausd_pairs_dists2, dists[self.iu1], decimal=6, err_msg=err_msg)
def test_dist_mat_to_vec_func_i_equals_j(self, N, i, j): """Test that ValueError is raised when i == j or i,j == N""" with pytest.raises(ValueError): PSA.dist_mat_to_vec(N, i, j)
def test_dist_mat_to_vec_input_numpy_integer_16(self): """Test whether inputs are supported as numpy integers rather than normal Integers""" err_msg = "dist_mat_to_vec function returning wrong values" assert_equal( PSA.dist_mat_to_vec(np.int16(5), np.int16(3), np.int16(4)), np.int16(9), err_msg)
def test_dist_mat_to_vec_i_greater_j(self): """Test the index of corresponding distance vector is correct if i > j""" err_msg = "dist_mat_to_vec function returning wrong values" assert_equal(PSA.dist_mat_to_vec(5, 4, 3), 9, err_msg)
def test_dist_mat_to_vec_func_out_of_bounds(self): """Test that ValueError is raised when i or j or both are out of bounds of N""" # Check if i is out of bounds of N with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, 6, 4) # Check if j is out of bounds of N with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, 4, 6) # Check if both i and j are out of bounds of N with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, 6, 7) # Check if i is negative with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, -1, 2) # Check if j is negative with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, 1, -2) # Check if N is less than 2 with self.assertRaises(ValueError): PSA.dist_mat_to_vec(1, 0, 0)
def test_dist_mat_to_vec_i_less_j(self): """Test the index of corresponding distance vector is correct if i < j""" err_msg = "dist_mat_to_vec function returning wrong values" assert_equal(PSA.dist_mat_to_vec(5, 3, 4), 9, err_msg)
def test_dist_mat_to_vec_func_out_of_bounds(self): """Test that ValueError is raised when i or j or both are out of bounds of N""" # Check if i is out of bounds of N with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, 6, 4) # Check if j is out of bounds of N with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, 4, 6) # Check if both i and j are out of bounds of N with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, 6, 7) # Check if i is negative with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, -1, 2) # Check if j is negative with self.assertRaises(ValueError): PSA.dist_mat_to_vec(5, 1, -2) # Check if N is less than 2 with self.assertRaises(ValueError): PSA.dist_mat_to_vec(1, 0, 0)
def test_dist_mat_to_vec_input_numpy_integer_16(self): """Test whether inputs are supported as numpy integers rather than normal Integers""" err_msg = "dist_mat_to_vec function returning wrong values" assert_equal(PSA.dist_mat_to_vec(np.int16(5), np.int16(3), np.int16(4)), np.int16(9), err_msg)