Skip to content

Commit

Permalink
Add test and reno
Browse files Browse the repository at this point in the history
  • Loading branch information
ElePT committed Jan 19, 2023
1 parent 4827256 commit 43fd417
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions releasenotes/notes/fix-qpy-mcxgray-421cf8f673f24238.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Fixed a bug in QPY (:mod:`qiskit.qpy`) where circuits containing gates of class
:class:`.MCXGrayCode` would fail to serialize.
See `#9390 <https://github.com/Qiskit/qiskit-terra/issues/9390>`__.
14 changes: 12 additions & 2 deletions test/python/circuit/test_circuit_load_from_qpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@
from qiskit.circuit.quantumregister import Qubit
from qiskit.circuit.random import random_circuit
from qiskit.circuit.gate import Gate
from qiskit.circuit.library import XGate, QFT, QAOAAnsatz, PauliEvolutionGate, DCXGate, MCU1Gate
from qiskit.circuit.library import (
XGate,
QFT,
QAOAAnsatz,
PauliEvolutionGate,
DCXGate,
MCU1Gate,
MCXGrayCode,
)
from qiskit.circuit.instruction import Instruction
from qiskit.circuit.parameter import Parameter
from qiskit.circuit.parametervector import ParameterVector
Expand Down Expand Up @@ -1043,9 +1051,11 @@ def test_open_controlled_gate(self):

def test_standard_control_gates(self):
"""Test standard library controlled gates."""
qc = QuantumCircuit(3)
qc = QuantumCircuit(6)
mcu1_gate = MCU1Gate(np.pi, 2)
mcx_gray_gate = MCXGrayCode(5)
qc.append(mcu1_gate, [0, 2, 1])
qc.append(mcx_gray_gate, list(range(0, 6)))
qc.mcp(np.pi, [0, 2], 1)
qc.mct([0, 2], 1)
qc.mcx([0, 2], 1)
Expand Down

0 comments on commit 43fd417

Please sign in to comment.