diff --git a/pyzx/circuit/qasmparser.py b/pyzx/circuit/qasmparser.py index ca10fe8e..4e7539ef 100644 --- a/pyzx/circuit/qasmparser.py +++ b/pyzx/circuit/qasmparser.py @@ -169,13 +169,13 @@ def parse_command(self, c: str, registers: Dict[str,Tuple[int,int]]) -> List[Gat for g in circ.gates: gates.append(g.reposition(argset)) continue - if name in ("x", "z", "s", "t", "h", "sdg", "tdg"): - if name in ("sdg", "tdg"): + if name in ('x', 'z', 's', 't', 'h', 'sdg', 'tdg'): + if name in ('sdg', 'tdg'): g = qasm_gate_table[name](argset[0],adjoint=True) # type: ignore # mypy can't handle - else: g = qasm_gate_table[name](argset[0]) # type: ignore # - Gate subclasses with different numbers of parameters gates.append(g) continue - if name.startswith(("rx", "ry", "rz", "p", "u1", "crz")): + if name.startswith(('rx', 'ry', 'rz', 'p', 'u1', 'crz')): i = name.find('(') j = name.find(')') if i == -1 or j == -1: raise TypeError("Invalid specification {}".format(name)) @@ -201,7 +201,7 @@ def parse_command(self, c: str, registers: Dict[str,Tuple[int,int]]) -> List[Gat gates.append(NOT(argset[0])) gates.append(ZPhase(argset[0],phase=-phase/2)) gates.append(NOT(argset[0])) - elif name.startswith("ry"): gates.append(YPhase(argset[0],phase=phase)) + elif name.startswith('ry'): gates.append(YPhase(argset[0],phase=phase)) else: raise TypeError("Invalid specification {}".format(name)) continue if name.startswith('u2') or name.startswith('u3'): # see https://arxiv.org/pdf/1707.03429.pdf @@ -225,11 +225,11 @@ def parse_command(self, c: str, registers: Dict[str,Tuple[int,int]]) -> List[Gat gates.append(XPhase(argset[0],phase=Fraction(1,2))) gates.append(ZPhase(argset[0],phase=(phases[1]+3)%2)) continue - if name in ("cx","CX","cz","ch", "swap"): + if name in ('cx', 'CX', 'cz', 'ch', 'swap'): g = qasm_gate_table[name](control=argset[0],target=argset[1]) # type: ignore gates.append(g) continue - if name in ("ccx", "ccz"): + if name in ('ccx', 'ccz'): g = qasm_gate_table[name](ctrl1=argset[0],ctrl2=argset[1],target=argset[2]) # type: ignore gates.append(g) continue diff --git a/tests/test_cnot_mapper.py b/tests/test_cnot_mapper.py index 56aee605..cd1c9235 100644 --- a/tests/test_cnot_mapper.py +++ b/tests/test_cnot_mapper.py @@ -1,3 +1,20 @@ +# PyZX - Python library for quantum circuit rewriting +# and optimization using the ZX-calculus +# Copyright (C) 2018 - Aleks Kissinger and John van de Wetering + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + import copy import unittest import sys diff --git a/tests/test_phasepoly.py b/tests/test_phasepoly.py index 6ea18584..f4f17437 100644 --- a/tests/test_phasepoly.py +++ b/tests/test_phasepoly.py @@ -1,3 +1,20 @@ +# PyZX - Python library for quantum circuit rewriting +# and optimization using the ZX-calculus +# Copyright (C) 2018 - Aleks Kissinger and John van de Wetering + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + from typing import List import unittest import sys, os diff --git a/tests/test_ry.py b/tests/test_ry.py index 96508cba..2506c592 100644 --- a/tests/test_ry.py +++ b/tests/test_ry.py @@ -1,7 +1,20 @@ +# PyZX - Python library for quantum circuit rewriting +# and optimization using the ZX-calculus +# Copyright (C) 2018 - Aleks Kissinger and John van de Wetering + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import unittest import random import sys