Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[work in progress] Clarify "conjugate" method purpose #13395

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qiskit/circuit/library/generalized_gates/unitary.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def inverse(self, annotated: bool = False):
return self.adjoint()

def conjugate(self):
"""Return the conjugate of the unitary."""
"""Return the complex conjugate of the unitary with respect to the representation returned by ``to_matrix``."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider linking to the method:

Suggested change
"""Return the complex conjugate of the unitary with respect to the representation returned by ``to_matrix``."""
"""Return the complex conjugate of the unitary with respect to the representation returned by :meht:`~UnitaryGate.to_matrix`."""

return UnitaryGate(numpy.conj(self.to_matrix()))

def adjoint(self):
Expand Down
2 changes: 1 addition & 1 deletion qiskit/quantum_info/operators/mixins/adjoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def adjoint(self) -> Self:

@abstractmethod
def conjugate(self) -> Self:
"""Return the conjugate of the CLASS."""
"""Return the complex conjugate of the CLASS."""

@abstractmethod
def transpose(self) -> Self:
Expand Down
2 changes: 1 addition & 1 deletion qiskit/quantum_info/operators/symplectic/pauli_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ def _multiply(self, other):
return PauliList(super()._multiply(other))

def conjugate(self):
"""Return the conjugate of each Pauli in the list."""
"""Return the complex conjugate of each Pauli in the list with respect to the Z basis."""
return PauliList(super().conjugate())

def transpose(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def __setitem__(self, key, value):
# ---------------------------------------------------------------------

def conjugate(self):
"""Return the complex conjugate with respect to the representation returned by ``to_matrix``."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider linking to the method:

Suggested change
"""Return the complex conjugate with respect to the representation returned by ``to_matrix``."""
"""Return the complex conjugate with respect to the representation returned by :meth:`~SparsePauliOp.to_matrix`."""

# Conjugation conjugates phases and also Y.conj() = -Y
# Hence we need to multiply conjugated coeffs by -1
# for rows with an odd number of Y terms.
Expand Down
2 changes: 1 addition & 1 deletion qiskit/quantum_info/states/densitymatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def to_operator(self) -> Operator:
return Operator(self.data, input_dims=dims, output_dims=dims)

def conjugate(self):
"""Return the conjugate of the density matrix."""
"""Return the complex conjugate of the density matrix."""
return DensityMatrix(np.conj(self.data), dims=self.dims())

def trace(self):
Expand Down
3 changes: 2 additions & 1 deletion qiskit/quantum_info/states/stabilizerstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def to_operator(self) -> Operator:
return Clifford(self.clifford).to_operator()

def conjugate(self):
"""Return the conjugate of the operator."""
"""Return the complex conjugate of the underlying Clifford operator with
respect to the representation returned by the operator's ``to_matrix`` method."""
ret = self.copy()
ret._data = ret._data.conjugate()
return ret
Expand Down
2 changes: 1 addition & 1 deletion qiskit/quantum_info/states/statevector.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def to_operator(self) -> Operator:
return Operator(mat, input_dims=self.dims(), output_dims=self.dims())

def conjugate(self) -> Statevector:
"""Return the conjugate of the operator."""
"""Return the complex conjugate of the state vector."""
return Statevector(np.conj(self.data), dims=self.dims())

def trace(self) -> np.float64:
Expand Down
Loading