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

Don't wrap global phase if parameterized #689

Merged
merged 5 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading