Skip to content

Commit

Permalink
Merge pull request #1420 from qiboteam/varible-tuple-hint
Browse files Browse the repository at this point in the history
Tuple-related type hints
  • Loading branch information
alecandido authored Aug 17, 2024
2 parents 4f57f37 + e1179f8 commit 8fb9af9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/qibo/gates/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,17 @@ def to_json(self):
return json.dumps(self.raw)

@property
def target_qubits(self) -> Tuple[int]:
def target_qubits(self) -> Tuple[int, ...]:
"""Tuple with ids of target qubits."""
return self._target_qubits

@property
def control_qubits(self) -> Tuple[int]:
def control_qubits(self) -> Tuple[int, ...]:
"""Tuple with ids of control qubits sorted in increasing order."""
return tuple(sorted(self._control_qubits))

@property
def qubits(self) -> Tuple[int]:
def qubits(self) -> Tuple[int, ...]:
"""Tuple with ids of all qubits (control and target) that the gate acts."""
return self.control_qubits + self.target_qubits

Expand Down
4 changes: 3 additions & 1 deletion src/qibo/gates/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def __init__(
self.basis.append(gate)

@staticmethod
def _get_bitflip_tuple(qubits: Tuple[int], probs: "ProbsType") -> Tuple[float]:
def _get_bitflip_tuple(
qubits: Tuple[int, ...], probs: "ProbsType"
) -> Tuple[float, ...]:
if isinstance(probs, float):
if probs < 0 or probs > 1: # pragma: no cover
raise_error(ValueError, f"Invalid bitflip probability {probs}.")
Expand Down

0 comments on commit 8fb9af9

Please sign in to comment.