def test_rotateby_bad_direction(rotate_universes, direction): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts # what if the box is in the wrong format? angle = 90 point = [0, 0, 0] with pytest.raises(ValueError): rotateby(angle, direction, point=point)(ts)
def test_rotateby_bad_direction(rotate_universes, direction): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts # what if the box is in the wrong format? angle = 90 point = [0, 0, 0] with pytest.raises(ValueError): rotateby(angle, direction, point=point)(ts)
def test_rotateby_bad_point(rotate_universes, point): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts # what if the box is in the wrong format? angle = 90 vector = [0, 0, 1] bad_position = point with pytest.raises(ValueError): rotateby(angle, vector, point=bad_position)(ts)
def test_rotateby_no_args(rotate_universes): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts angle = 90 vector = [0, 0, 1] # if no point or AtomGroup are passed to the function # it should raise a ValueError with pytest.raises(ValueError): rotateby(angle, vector)(ts)
def test_rotateby_bad_point(rotate_universes, point): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts # what if the box is in the wrong format? angle = 90 vector = [0, 0, 1] bad_position = point with pytest.raises(ValueError): rotateby(angle, vector, point=bad_position)(ts)
def test_rotateby_no_args(rotate_universes): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts angle = 90 vector = [0, 0, 1] # if no point or AtomGroup are passed to the function # it should raise a ValueError with pytest.raises(ValueError): rotateby(angle, vector)(ts)
def test_rotateby_bad_pbc(rotate_universes): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts ag = rotate_universes[0].residues[0].atoms # is pbc passed to the center methods? # if yes it should raise an exception for boxes that are zero in size vector = [1, 0, 0] angle = 90 with pytest.raises(ValueError): rotateby(angle, vector, ag=ag, wrap=True)(ts)
def test_rotateby_bad_ag(rotate_universes, ag): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts ag = rotate_universes[0].residues[0].atoms # what happens if something other than an AtomGroup is given? angle = 90 vector = [0, 0, 1] bad_ag = 1 with pytest.raises(ValueError): rotateby(angle, vector, ag=bad_ag)(ts)
def test_rotateby_no_masses(rotate_universes): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts ag = rotate_universes[0].residues[0].atoms # if the universe has no masses and `mass` is passed as the center arg angle = 90 vector = [0, 0, 1] bad_center = "mass" with pytest.raises(TypeError): rotateby(angle, vector, ag=ag, weights=bad_center)(ts)
def test_rotateby_no_masses(rotate_universes): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts ag = rotate_universes[0].residues[0].atoms # if the universe has no masses and `mass` is passed as the center arg angle = 90 vector = [0, 0, 1] bad_center = "mass" with pytest.raises(TypeError): rotateby(angle, vector, ag = ag, weights=bad_center)(ts)
def test_rotateby_bad_weights(rotate_universes, weights): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts ag = rotate_universes[0].residues[0].atoms # what if a wrong center type name is passed? angle = 90 vector = [0, 0, 1] bad_weights = " " with pytest.raises(TypeError): rotateby(angle, vector, ag = ag, weights=bad_weights)(ts)
def test_rotateby_bad_pbc(rotate_universes): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts ag = rotate_universes[0].residues[0].atoms # is pbc passed to the center methods? # if yes it should raise an exception for boxes that are zero in size vector = [1, 0, 0] angle = 90 with pytest.raises(ValueError): rotateby(angle, vector, ag = ag, wrap=True)(ts)
def test_rotateby_bad_ag(rotate_universes, ag): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts ag = rotate_universes[0].residues[0].atoms # what happens if something other than an AtomGroup is given? angle = 90 vector = [0, 0, 1] bad_ag = 1 with pytest.raises(ValueError): rotateby(angle, vector, ag = bad_ag)(ts)
def test_rotateby_bad_weights(rotate_universes, weights): # this universe as a box size zero ts = rotate_universes[0].trajectory.ts ag = rotate_universes[0].residues[0].atoms # what if a wrong center type name is passed? angle = 90 vector = [0, 0, 1] bad_weights = " " with pytest.raises(TypeError): rotateby(angle, vector, ag=ag, weights=bad_weights)(ts)
def test_rotateby_vector(rotate_universes, vector): # what happens when we use a custom point for the axis of rotation? ref_u = rotate_universes[0] trans_u = rotate_universes[1] trans = trans_u.trajectory.ts ref = ref_u.trajectory.ts point = [0, 0, 0] angle = 90 vec = vector.reshape(3, ) matrix = rotation_matrix(np.deg2rad(angle), vec, point) ref_u.atoms.transform(matrix) transformed = rotateby(angle, vector, point=point)(trans) assert_array_almost_equal(transformed.positions, ref.positions, decimal=6)
def test_rotateby_vector(rotate_universes, vector): # what happens when we use a custom point for the axis of rotation? ref_u = rotate_universes[0] trans_u = rotate_universes[1] trans = trans_u.trajectory.ts ref = ref_u.trajectory.ts point = [0, 0, 0] angle = 90 vec = vector.reshape(3, ) matrix = rotation_matrix(np.deg2rad(angle), vec, point) ref_u.atoms.transform(matrix) transformed = rotateby(angle, vector, point=point)(trans) assert_array_almost_equal(transformed.positions, ref.positions, decimal=6)
def test_rotateby_atomgroup_cog_nopbc(rotate_universes): # what happens when we rotate arround the center of geometry of a residue # without pbc? ref_u = rotate_universes[0] trans_u = rotate_universes[1] trans = trans_u.trajectory.ts ref = ref_u.trajectory.ts center_pos = [6, 7, 8] vector = [1, 0, 0] angle = 90 matrix = rotation_matrix(np.deg2rad(angle), vector, center_pos) ref_u.atoms.transform(matrix) selection = trans_u.residues[0].atoms transformed = rotateby(angle, vector, ag=selection, weights=None)(trans) assert_array_almost_equal(transformed.positions, ref.positions, decimal=6)
def test_rotateby_atomgroup_com_pbc(rotate_universes): # what happens when we rotate arround the center of mass of a residue # with pbc? ref_u = rotate_universes[0] trans_u = rotate_universes[1] trans = trans_u.trajectory.ts ref = ref_u.trajectory.ts vector = [1,0,0] angle = 90 selection = trans_u.residues[0].atoms center_pos = selection.center_of_mass(pbc=True) matrix = rotation_matrix(np.deg2rad(angle), vector, center_pos) ref_u.atoms.transform(matrix) transformed = rotateby(angle, vector, ag=selection, weights='mass', wrap=True)(trans) assert_array_almost_equal(transformed.positions, ref.positions, decimal=6)
def test_rotateby_atomgroup_cog_nopbc(rotate_universes): # what happens when we rotate arround the center of geometry of a residue # without pbc? ref_u = rotate_universes[0] trans_u = rotate_universes[1] trans = trans_u.trajectory.ts ref = ref_u.trajectory.ts center_pos = [6,7,8] vector = [1,0,0] angle = 90 matrix = rotation_matrix(np.deg2rad(angle), vector, center_pos) ref_u.atoms.transform(matrix) selection = trans_u.residues[0].atoms transformed = rotateby(angle, vector, ag=selection, weights=None)(trans) assert_array_almost_equal(transformed.positions, ref.positions, decimal=6)
def test_rotateby_atomgroup_com_pbc(rotate_universes): # what happens when we rotate arround the center of mass of a residue # with pbc? ref_u = rotate_universes[0] trans_u = rotate_universes[1] trans = trans_u.trajectory.ts ref = ref_u.trajectory.ts vector = [1, 0, 0] angle = 90 selection = trans_u.residues[0].atoms center_pos = selection.center_of_mass(pbc=True) matrix = rotation_matrix(np.deg2rad(angle), vector, center_pos) ref_u.atoms.transform(matrix) transformed = rotateby(angle, vector, ag=selection, weights='mass', wrap=True)(trans) assert_array_almost_equal(transformed.positions, ref.positions, decimal=6)