Skip to content
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
4 changes: 3 additions & 1 deletion qiskit/dagcircuit/dagcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,9 @@ def substitute_node_with_dag(self, node, input_dag, wires=None):
replay_node.cargs)

if in_dag.global_phase:
self.global_phase += in_dag.global_phase
from sympy import evaluate
with evaluate(False):
self.global_phase += in_dag.global_phase

if wires is None:
wires = in_dag.wires
Expand Down
4 changes: 3 additions & 1 deletion qiskit/transpiler/passes/basis/basis_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ def run(self, dag):
dag.substitute_node(node, dag_op, inplace=True)

if bound_target_dag.global_phase:
dag.global_phase += bound_target_dag.global_phase
from sympy import evaluate
with evaluate(False):
dag.global_phase += bound_target_dag.global_phase
else:
dag.substitute_node_with_dag(node, bound_target_dag)
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
upgrade:
- |
Following transpilation of a parameterized :class:`~qiskit.circuit.QuantumCircuit`,
the :attr:`~qiskit.circuit.QuantumCircuit.global_phase` attribute of output circuit
may no longer be returned in a simplified form, if the global phase is a
:class:`~qiskit.circuit.ParameterExpression`.

For example,::

qc = QuantumCircuit(1)
theta = Parameter('theta')

qc.rz(theta, 0)
qc.rz(-theta, 0)

transpile(qc, basis_gates=['p']).global_phase

previously returned ``0``, but will now return ``-0.5*theta + 0.5*theta``.