Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Don't wrap global phase if parameterized (#689)
Browse files Browse the repository at this point in the history
* Don't wrap parameterized global phase

* Just use dag_circuit.global_phase setter

Already wrapping phase

* Release note

* Restore final line

---------

Co-authored-by: Kevin Tian <[email protected]>
  • Loading branch information
dieris and kt474 authored Aug 8, 2023
1 parent 954c5a2 commit ab06fd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def _constrained_length(values: np.array) -> np.array:
idle_after += gate_length
dd_ind += 1

self._block_dag.global_phase = self._mod_2pi(
self._block_dag.global_phase = (
self._block_dag.global_phase + sequence_gphase
)
return
Expand All @@ -565,11 +565,3 @@ def _constrained_length(values: np.array) -> np.array:
block_idx, t_start, Delay(time_interval, self._block_dag.unit), qubit
)
return

@staticmethod
def _mod_2pi(angle: float, atol: float = 0) -> float:
"""Wrap angle into interval [-π,π). If within atol of the endpoint, clamp to -π"""
wrapped = (angle + np.pi) % (2 * np.pi) - np.pi
if abs(wrapped - np.pi) < atol:
wrapped = -np.pi
return wrapped
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
2pi wrapping cannot be applied on a parameterized global phase. Use the DAGCircuit global_phase setter to wrap the phase for floats only.

0 comments on commit ab06fd9

Please sign in to comment.