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

Minor cosmetic changes to make codebase more consistent. #155

Merged
merged 2 commits into from
Sep 16, 2023
Merged
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
12 changes: 6 additions & 6 deletions pyzx/circuit/qasmparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand All @@ -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
Expand Down
17 changes: 17 additions & 0 deletions tests/test_cnot_mapper.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 17 additions & 0 deletions tests/test_phasepoly.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 13 additions & 0 deletions tests/test_ry.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading