Skip to content

Commit

Permalink
TOBESQUASHED
Browse files Browse the repository at this point in the history
  • Loading branch information
rht committed Oct 24, 2019
1 parent edf8efa commit f0d95f6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pyquil/paulis.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import numpy as np
import copy

from typing import Dict, Iterable, List, Optional, Tuple, Union
from typing import Dict, FrozenSet, Iterable, Iterator, List, Optional, Tuple, Union

from pyquil.quilatom import QubitPlaceholder

Expand Down Expand Up @@ -119,14 +119,14 @@ def id(self, sort_ops: bool = True) -> str:
else:
return ''.join("{}{}".format(p, q) for q, p in self._ops.items())

def operations_as_set(self):
def operations_as_set(self) -> FrozenSet[Tuple[int, str]]:
"""
Return a frozenset of operations in this term.
Use this in place of :py:func:`id` if the order of operations in the term does not
matter.
:return: frozenset of (op_str, coefficient) representing Pauli operations
:return: frozenset of (qubit, op_str) representing Pauli operations
"""
return frozenset(self._ops.items())

Expand All @@ -139,7 +139,7 @@ def __eq__(self, other: object) -> bool:
return (self.operations_as_set() == other.operations_as_set()
and np.isclose(self.coefficient, other.coefficient))

def __hash__(self):
def __hash__(self) -> int:
return hash((
round(self.coefficient.real * HASH_PRECISION),
round(self.coefficient.imag * HASH_PRECISION),
Expand Down Expand Up @@ -170,7 +170,7 @@ def copy(self) -> 'PauliTerm':
return new_term

@property
def program(self):
def program(self) -> Program:
return Program([QUANTUM_GATES[gate](q) for q, gate in self])

def get_qubits(self) -> List[int]:
Expand All @@ -181,7 +181,7 @@ def get_qubits(self) -> List[int]:
def __getitem__(self, i: int) -> str:
return self._ops.get(i, "I")

def __iter__(self):
def __iter__(self) -> Iterator[Tuple[int, str]]:
for i in self.get_qubits():
yield i, self[i]

Expand Down

0 comments on commit f0d95f6

Please sign in to comment.