def test_small_rotation(self): """Simple test of functionality with small rotation""" rotation = compose_euler(pi / 10, pi / 10, pi / 10) alpha, beta, gamma = decompose_euler(rotation) self.assertAlmostEqual(alpha, pi / 10) self.assertAlmostEqual(beta, pi / 10) self.assertAlmostEqual(gamma, pi / 10)
def test_very_small_rotation(self): """Test that the decomposition is stable at very small rotation""" rotation = compose_euler(pi / 10000, pi / 10000, pi / 10000) alpha, beta, gamma = decompose_euler(rotation) self.assertAlmostEqual(alpha, pi / 10000) self.assertAlmostEqual(beta, pi / 10000) self.assertAlmostEqual(gamma, pi / 10000)
def test_pi_rotation(self): """Test the cases of singularity""" rotation = compose_euler(0, pi, 9 * pi / 10) alpha, beta, gamma = decompose_euler(rotation) self.assertAlmostEqual(alpha, 0) self.assertAlmostEqual(beta, pi) self.assertAlmostEqual(gamma, 9 * pi / 10)
def test_large_rotation(self): """Simple test of functionality with large rotation""" rotation = compose_euler(9 * pi / 10, 9 * pi / 10, 9 * pi / 10) alpha, beta, gamma = decompose_euler(rotation) self.assertAlmostEqual(alpha, 9 * pi / 10) self.assertAlmostEqual(beta, 9 * pi / 10) self.assertAlmostEqual(gamma, 9 * pi / 10)
def test_close_to_pi_rotation(self): """Test that the decomposition is stable for a rotation that is close to pi""" rotation = compose_euler(9999 * pi / 10000, 9999 * pi / 10000, 9999 * pi / 10000) alpha, beta, gamma = decompose_euler(rotation) self.assertAlmostEqual(alpha, 9999 * pi / 10000) self.assertAlmostEqual(beta, 9999 * pi / 10000) self.assertAlmostEqual(gamma, 9999 * pi / 10000)
def pulse_pattern(self, pattern): while pattern: if pattern.pop() == 1: self.pulse_and_precess() else: self.precess() alpha, beta, gamma = decompose_euler(self.u, unimodular_check=False) self.alpha_list.append(alpha) self.beta_list.append(beta) self.gamma_list.append(gamma)
def pulse_pattern(self, pattern): while pattern: if pattern.pop() == 1: self.pulse_and_precess() else: self.precess() # Keep track of the euler angles. alpha, beta, gamma = decompose_euler(self.u) self.alpha_list.append(alpha) self.beta_list.append(beta) self.gamma_list.append(gamma)
def _record_euler(self): alpha, beta, gamma = decompose_euler(self.u, unimodular_check=False) self.alpha_list.append(alpha) self.beta_list.append(beta) self.gamma_list.append(gamma)