Skip to content

Commit

Permalink
[minor] change swap param name and fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
01110011011101010110010001101111 committed Aug 4, 2023
1 parent 625126e commit e763d38
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions torchquantum/layer/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ def __init__(
self,
n_wires: int = None,
wires: Iterable = None,
add_swaps: bool = True,
do_swaps: bool = True,
inverse: bool = False,
):
"""
Expand All @@ -930,7 +930,7 @@ def __init__(
Args:
n_wires (int): Number of wires for the QFT as an integer
wires (Iterable): Wires to perform the QFT as an Iterable
add_swaps (bool): Whether or not to add the final swaps in a boolean format
do_swaps (bool): Whether or not to add the final swaps in a boolean format
inverse (bool): Whether to create an inverse QFT layer in a boolean format
"""
super().__init__()
Expand All @@ -945,7 +945,7 @@ def __init__(

self.n_wires = n_wires
self.wires = wires
self.add_swaps = add_swaps
self.do_swaps = do_swaps

if inverse:
self.gates_all = self.build_inverse_circuit()
Expand All @@ -955,7 +955,7 @@ def __init__(
def build_circuit(self):
"""Construct a QFT circuit."""

operation_list = nn.ModuleList()
operation_list = []

# add the H and CU1 gates
for top_wire in range(self.n_wires):
Expand All @@ -971,7 +971,7 @@ def build_circuit(self):
)

# add swaps if specified
if self.add_swaps:
if self.do_swaps:
for wire in range(self.n_wires // 2):
operation_list.append(
{
Expand All @@ -991,7 +991,7 @@ def build_inverse_circuit(self):
operation_list = []

# add swaps if specified
if self.add_swaps:
if self.do_swaps:
for wire in range(self.n_wires // 2):
operation_list.append(
{
Expand Down

0 comments on commit e763d38

Please sign in to comment.