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

Add qubits to PauliStringPhasor #5565

Merged
merged 25 commits into from
Jun 24, 2022
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a4e977f
Add qubits to PauliStringPhasor
dabacon Jun 21, 2022
9f07b53
Merge branch 'master' into fixphaso
dabacon Jun 21, 2022
c3b5bf2
fix gate operation test
dabacon Jun 21, 2022
db7ffd1
Update cirq-core/cirq/ops/pauli_string_phasor.py
dabacon Jun 21, 2022
c714db1
Update cirq-core/cirq/ops/pauli_string_phasor.py
dabacon Jun 21, 2022
dafbf70
Update cirq-core/cirq/ops/pauli_string_phasor.py
dabacon Jun 21, 2022
58b7f4d
Update cirq-core/cirq/ops/pauli_string_phasor.py
dabacon Jun 21, 2022
11a8e00
review comments
dabacon Jun 22, 2022
5517103
Merge branch 'master' into fixphaso
dabacon Jun 22, 2022
0f3637f
Merge branch 'master' into fixphaso
dabacon Jun 22, 2022
a7e7cb0
Merge branch 'master' into fixphaso
dabacon Jun 22, 2022
e42f8b6
Merge branch 'master' into fixphaso
dabacon Jun 23, 2022
52ca61a
Merge branch 'master' into fixphaso
dabacon Jun 23, 2022
faac9e1
Update cirq-core/cirq/ops/pauli_string_phasor.py
dabacon Jun 23, 2022
b648751
Update cirq-core/cirq/ops/pauli_string_phasor.py
dabacon Jun 23, 2022
43a0095
review comments
dabacon Jun 23, 2022
118b285
fix nits
dabacon Jun 23, 2022
c943d05
Merge branch 'fixphaso' of github.com:dabacon/Cirq into fixphaso
dabacon Jun 23, 2022
d65eb71
Merge branch 'master' into fixphaso
dabacon Jun 23, 2022
b471857
Merge branch 'master' into fixphaso
dabacon Jun 24, 2022
f79e319
fix lint
dabacon Jun 24, 2022
a7b98a0
fix
dabacon Jun 24, 2022
798ba80
fix mypy
dabacon Jun 24, 2022
e80a822
Merge branch 'master' into fixphaso
dabacon Jun 24, 2022
6cef047
Merge branch 'master' into fixphaso
dabacon Jun 24, 2022
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
Prev Previous commit
Next Next commit
review comments
  • Loading branch information
dabacon committed Jun 23, 2022
commit 43a0095dd1fcfdb722b48f501682d47df088c933
21 changes: 10 additions & 11 deletions cirq-core/cirq/ops/pauli_string_phasor.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def __init__(
exponent_pos=exponent_pos,
)
super().__init__(gate, qubits or pauli_string.qubits)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
super().__init__(gate, qubits or pauli_string.qubits)
super().__init__(gate, qubits)

it = iter(self.qubits)
self._pauli_string = gate.dense_pauli_string.on(*self.qubits)

@property
Expand All @@ -115,17 +114,17 @@ def gate(self) -> 'cirq.PauliStringPhasorGate':
return cast(PauliStringPhasorGate, self._gate)

@property
def exponent_neg(self):
def exponent_neg(self) -> Union[int, float, sympy.Expr]:
"""The negative exponent."""
return self.gate.exponent_neg

@property
def exponent_pos(self):
def exponent_pos(self) -> Union[int, float, sympy.Expr]:
"""The positive exponent."""
return self.gate.exponent_pos

@property
def pauli_string(self):
def pauli_string(self) -> 'cirq.PauliString':
"""The underlying pauli string."""
return self._pauli_string

Expand All @@ -137,7 +136,7 @@ def exponent_relative(self) -> Union[int, float, sympy.Expr]:
def _value_equality_values_(self):
return (self.pauli_string, self.qubits, self.exponent_neg, self.exponent_pos)

def equal_up_to_global_phase(self, other):
def equal_up_to_global_phase(self, other: 'PauliStringPhasor') -> bool:
"""Checks equality of two PauliStringPhasors, up to global phase."""
if isinstance(other, PauliStringPhasor):
return (
Expand All @@ -147,7 +146,7 @@ def equal_up_to_global_phase(self, other):
)
return False

def map_qubits(self, qubit_map: Dict[raw_types.Qid, raw_types.Qid]):
def map_qubits(self, qubit_map: Dict[raw_types.Qid, raw_types.Qid]) -> 'PauliStringPhasor':
"""Maps the qubits inside the PauliStringPhasor.

Args:
Expand Down Expand Up @@ -315,24 +314,24 @@ def exponent_relative(self) -> Union[int, float, sympy.Expr]:
return value.canonicalize_half_turns(self.exponent_neg - self.exponent_pos)

@property
def exponent_neg(self):
def exponent_neg(self) -> Union[int, float, sympy.Expr]:
"""The negative exponent."""
return self._exponent_neg

@property
def exponent_pos(self):
def exponent_pos(self) -> Union[int, float, sympy.Expr]:
"""The positive exponent."""
return self._exponent_pos

@property
def dense_pauli_string(self):
def dense_pauli_string(self) -> 'cirq.DensePauliString':
"""The underlying DensePauliString."""
return self._dense_pauli_string

def _value_equality_values_(self):
return (self.dense_pauli_string, self.exponent_neg, self.exponent_pos)

def equal_up_to_global_phase(self, other):
def equal_up_to_global_phase(self, other: 'cirq.PauliStringPhasorGate') -> bool:
"""Checks equality of two PauliStringPhasors, up to global phase."""
if isinstance(other, PauliStringPhasorGate):
rel1 = self.exponent_relative
Expand All @@ -347,7 +346,7 @@ def __pow__(self, exponent: Union[float, sympy.Symbol]) -> 'PauliStringPhasorGat
return NotImplemented
return PauliStringPhasorGate(self.dense_pauli_string, exponent_neg=pn, exponent_pos=pp)

def _has_unitary_(self):
def _has_unitary_(self) -> bool:
return not self._is_parameterized_()

def _to_z_basis_ops(self, qubits: Sequence['cirq.Qid']) -> Iterator[raw_types.Operation]:
Expand Down