Skip to content

Commit

Permalink
Fixing various typing issues (#87)
Browse files Browse the repository at this point in the history
## Description

This pull request addresses two minor typing issues:
* `MatrixFactoryGate.controlled` did not use the same parameter name as
the `controlled` method of the `Gate` protocol.
* One of the decomposition rules tried to access the
`num_control_qubits` attributes of a gate without ensuring that the gate
is of type `ControlledGate`.

## Please verify that you have completed the following steps

- [x] I have self-reviewed my code.
- [ ] I have included test cases validating introduced feature/fix.
- [ ] I have updated documentation.
  • Loading branch information
max-radin authored Jan 29, 2024
1 parent 4af3cdc commit 30503fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/orquestra/quantum/circuits/_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ def bind(self, symbols_map) -> "MatrixFactoryGate":
def replace_params(self, new_params: Tuple[Parameter, ...]) -> "MatrixFactoryGate":
return replace(self, params=new_params)

def controlled(self, num_controlled_qubits: int) -> Gate:
return ControlledGate(self, num_controlled_qubits)
def controlled(self, num_control_qubits: int) -> Gate:
return ControlledGate(self, num_control_qubits)

@property
def dagger(self) -> Union["MatrixFactoryGate", Gate]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def production(self, operation: GateOperation) -> Iterable[GateOperation]:
def preprocess_gate(gate):
return (
gate.controlled(operation.gate.num_control_qubits)
if operation.gate.name == "Control"
if isinstance(operation.gate, ControlledGate)
else gate
)

Expand Down

0 comments on commit 30503fb

Please sign in to comment.