Skip to content

Commit

Permalink
declare types?
Browse files Browse the repository at this point in the history
  • Loading branch information
ecpeterson committed Dec 16, 2019
1 parent e9c44ad commit 5a8d201
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pyquil/quilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ class DefGateByPaulis(DefGate):
Records a gate definition as the exponentiation of a PauliSum.
"""

def __init__(self, gate_name, parameters, arguments, body):
# actually, body is of type PauliSum, but circular imports are no good
def __init__(self, gate_name: str, parameters: list, arguments: list, body): # type: ignore
if not isinstance(gate_name, str):
raise TypeError("Gate name must be a string")

Expand All @@ -435,7 +436,8 @@ def out(self) -> str:
for term in self.body:
args, word = zip(*term._ops.items())
out += f" {''.join(word)}({term.coefficient}) " + " ".join(map(str, args)) + "\n"
return f"DEFGATE {self.name}({', '.join(map(str, self.parameters))}) {' '.join(map(str, self.arguments))} AS PAULI-SUM:\n" + out
return f"DEFGATE {self.name}({', '.join(map(str, self.parameters))}) " \ # type: ignore
f"{' '.join(map(str, self.arguments))} AS PAULI-SUM:\n" + out

def num_args(self) -> int:
return len(self.arguments)
Expand Down

0 comments on commit 5a8d201

Please sign in to comment.