def test_r(angle):
gate = _gates.R(angle)
gate2 = _gates.R(angle + 2 * math.pi)
expected_matrix = np.matrix([[1, 0], [0, cmath.exp(1j * angle)]])
assert gate.matrix.shape == expected_matrix.shape
assert np.allclose(gate.matrix, expected_matrix)
assert gate2.matrix.shape == expected_matrix.shape
assert np.allclose(gate2.matrix, expected_matrix)
assert gate == gate2
评论列表
文章目录