Skip to content

Commit

Permalink
Tuple unpacking bug fix in cut finder. (#591)
Browse files Browse the repository at this point in the history
* tuple unpacking bug fix, edit tests and type hints accordingly.

* remove extraneous type hint
  • Loading branch information
ibrahim-shehzad authored May 15, 2024
1 parent e3db27b commit 9d789f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion circuit_knitting/cutting/cut_finding/cutting_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def next_state_primitive(
new_state.bell_pairs.append((r2, rnew_2))
new_state.gamma_UB *= 16

new_state.add_action(self, gate_spec, ((1, w1, rnew_1), (2, w2, rnew_2)))
new_state.add_action(self, gate_spec, (1, w1, rnew_1), (2, w2, rnew_2))

return [new_state]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Action(NamedTuple):

action: DisjointSearchAction
gate_spec: GateSpec
args: list
args: list | tuple


class GateCutLocation(NamedTuple):
Expand Down Expand Up @@ -430,12 +430,12 @@ def add_action(
self,
action_obj: DisjointSearchAction,
gate_spec: GateSpec,
args: tuple | None = None,
*args: tuple,
) -> None:
"""Append the specified action to the list of search-space actions that have been performed."""
if action_obj.get_name() is not None:
self.actions = cast(list, self.actions)
self.actions.append(Action(action_obj, gate_spec, [args]))
self.actions.append(Action(action_obj, gate_spec, args))

def get_search_level(self) -> int:
"""Return the search level."""
Expand Down
6 changes: 3 additions & 3 deletions test/cutting/cut_finding/test_best_first_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,23 @@ def test_best_first_search(test_circuit: SimpleGateList):
gate=CircuitElement(name="cx", params=[], qubits=[3, 4], gamma=3),
cut_constraints=None,
),
[((1, 3), (2, 4))],
(((1, 3), (2, 4)),),
),
(
GateSpec(
instruction_id=13,
gate=CircuitElement(name="cx", params=[], qubits=[3, 5], gamma=3),
cut_constraints=None,
),
[((1, 3), (2, 5))],
(((1, 3), (2, 5)),),
),
(
GateSpec(
instruction_id=14,
gate=CircuitElement(name="cx", params=[], qubits=[3, 6], gamma=3),
cut_constraints=None,
),
[((1, 3), (2, 6))],
(((1, 3), (2, 6)),),
),
]

Expand Down

0 comments on commit 9d789f7

Please sign in to comment.