Skip to content

Commit

Permalink
added fix for efficient_su2
Browse files Browse the repository at this point in the history
  • Loading branch information
trigpolynom committed Dec 3, 2024
1 parent 8e2aaad commit ea6fa73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion qiskit/circuit/library/n_local/efficient_su2.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,13 @@ def efficient_su2(
if su2_gates is None:
su2_gates = ["ry", "rz"]

# Set entanglement_blocks to None when num_qubits == 1
entanglement_blocks = ['cx'] if num_qubits > 1 else []

return n_local(
num_qubits,
su2_gates,
["cx"],
entanglement_blocks,
entanglement,
reps,
insert_barriers,
Expand Down
6 changes: 6 additions & 0 deletions test/python/circuit/library/test_nlocal.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,12 @@ def test_efficient_su2(self):
expected = n_local(4, ["ry", "rz"], "cx", "reverse_linear", reps=3)
self.assertEqual(expected.assign_parameters(circuit.parameters), circuit)

def test_efficient_su2_numqubits_equal1(self):
"""Test the efficient SU(2) circuit."""
circuit = efficient_su2(1)
expected = n_local(1, ["ry", "rz"], [], "reverse_linear", reps=3)
self.assertEqual(expected.assign_parameters(circuit.parameters), circuit)

@data("fsim", "iswap")
def test_excitation_preserving(self, mode):
"""Test the excitation preserving circuit."""
Expand Down

0 comments on commit ea6fa73

Please sign in to comment.