def test_can_rotate_atoms(self, mock_transform): atom = Atom("C", 20, 30, 50) atom.rotate(math.pi / 2, "x", 10, a=20) self.assertEqual(mock_transform.call_args_list[0][0][1], 10) self.assertEqual(mock_transform.call_args_list[0][1], {"a": 20}) matrix_used = mock_transform.call_args_list[0][0][0] self.assertEqual([[round(val, 12) for val in row] for row in matrix_used], [[1, 0, 0], [0, 0, -1], [0, 1, 0]]) atom.rotate(math.pi / 18, "y") matrix_used = mock_transform.call_args_list[1][0][0] self.assertEqual([[round(val, 3) for val in row] for row in matrix_used], [[0.985, 0, 0.174], [0, 1, 0], [-0.174, 0, 0.985]]) atom.rotate(math.pi / -36, "z") matrix_used = mock_transform.call_args_list[2][0][0] self.assertEqual([[round(val, 3) for val in row] for row in matrix_used], [[0.996, 0.087, 0], [-0.087, 0.996, 0], [0, 0, 1]])
def test_rotation_axis_must_be_valid(self): atom = Atom("C", 20, 30, 50) with self.assertRaises(ValueError): atom.rotate(math.pi / 2, "w")