Skip to content

Commit

Permalink
Add mypy annotations (quantum_info)
Browse files Browse the repository at this point in the history
  • Loading branch information
Randl committed Jan 6, 2024
1 parent 7afef8f commit 7046f11
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion qiskit/quantum_info/operators/symplectic/clifford.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def _compose_general(cls, first: Clifford, second: Clifford) -> Clifford:
return Clifford(data, validate=False, copy=False)

@classmethod
def _compose_1q(cls, first, second) -> dict[tuple[bytes, bytes], Clifford]:
def _compose_1q(cls, first, second) -> Clifford:
# 1-qubit composition can be done with a simple lookup table; there are 24 elements in the
# 1q Clifford group, so 576 possible combinations, which is small enough to look up.
if cls._COMPOSE_1Q_LOOKUP is None:
Expand Down
4 changes: 2 additions & 2 deletions qiskit/quantum_info/operators/symplectic/pauli.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class initialization (``Pauli('-iXYZ')``). A ``Pauli`` object can be
_VALID_LABEL_PATTERN = re.compile(r"(?P<coeff>[+-]?1?[ij]?)(?P<pauli>[IXYZ]*)")
_CANONICAL_PHASE_LABEL = {"": 0, "-i": 1, "-": 2, "i": 3}

def __init__(self, data: str | tuple | Pauli | ScalarOp | QuantumCircuit | None = None):
def __init__(self, data: str | tuple | BasePauli | ScalarOp | QuantumCircuit | None = None):
"""Initialize the Pauli.
When using the symplectic array input data both z and x arguments must
Expand Down Expand Up @@ -493,7 +493,7 @@ def dot(self, other: Pauli, qargs: list | None = None, inplace: bool = False) ->
"""
return self.compose(other, qargs=qargs, front=True, inplace=inplace)

def tensor(self, other: Pauli) -> Pauli:
def tensor(self, other) -> Pauli:
if not isinstance(other, Pauli):
other = Pauli(other)
return Pauli(super().tensor(other))
Expand Down
4 changes: 2 additions & 2 deletions qiskit/quantum_info/states/measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ def concurrence(state: Statevector | DensityMatrix) -> float:
# If input is a density matrix it must be a 2-qubit state
if state.dim != 4:
raise QiskitError("Input density matrix must be a 2-qubit state.")
rho = DensityMatrix(state).data
rho_d = DensityMatrix(state).data
yy_mat = np.fliplr(np.diag([-1, 1, 1, -1]))
sigma = rho.dot(yy_mat).dot(rho.conj()).dot(yy_mat)
sigma = rho_d.dot(yy_mat).dot(rho_d.conj()).dot(yy_mat)
w = np.sort(np.real(la.eigvals(sigma)))
w = np.sqrt(np.maximum(w, 0.0))
return max(0.0, w[-1] - np.sum(w[0:-1]))
Expand Down
2 changes: 1 addition & 1 deletion qiskit/quantum_info/states/quantum_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, op_shape: OpShape | None = None):
# Set higher priority than Numpy array and matrix classes
__array_priority__ = 20

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
return isinstance(other, self.__class__) and self.dims() == other.dims()

@property
Expand Down

0 comments on commit 7046f11

Please sign in to comment.