Skip to content

Commit

Permalink
use numpy.pi everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
natestemen committed Jun 27, 2024
1 parent e68635e commit be16b7b
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions mitiq/interface/mitiq_pyquil/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
and modified to support a larger gateset (e.g. CPHASE).
"""

from math import pi
from typing import cast

import numpy as np
Expand Down Expand Up @@ -126,11 +125,11 @@ def _RX(angle: ParameterDesignator, q: QubitDesignator) -> Program:
A RX in terms of native RX(+-pi/2) and RZ gates.
"""
p = Program()
p += RZ(pi / 2, q)
p += RX(pi / 2, q)
p += RZ(np.pi / 2, q)
p += RX(np.pi / 2, q)
p += RZ(angle, q)
p += RX(-pi / 2, q)
p += RZ(-pi / 2, q)
p += RX(-np.pi / 2, q)
p += RZ(-np.pi / 2, q)
return p


Expand All @@ -139,9 +138,9 @@ def _RY(angle: ParameterDesignator, q: QubitDesignator) -> Program:
A RY in terms of RX(+-pi/2) and RZ(theta)
"""
p = Program()
p += RX(pi / 2, q)
p += RX(np.pi / 2, q)
p += RZ(angle, q)
p += RX(-pi / 2, q)
p += RX(-np.pi / 2, q)
return p


Expand Down Expand Up @@ -212,8 +211,8 @@ def is_magic_angle(angle: complex) -> bool:
Checks to see if an angle is 0, +/-pi/2, or +/-pi.
"""
return bool(
np.isclose(np.abs(angle), pi / 2)
or np.isclose(np.abs(angle), pi)
np.isclose(np.abs(angle), np.pi / 2)
or np.isclose(np.abs(angle), np.pi)
or np.isclose(angle, 0.0)
)

Expand Down

0 comments on commit be16b7b

Please sign in to comment.