Skip to content

Commit 94eb28d

Browse files
committed
Fix warnings from linters/formatters
1 parent 77840df commit 94eb28d

14 files changed

+213
-253
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ jobs:
7272
- name: Build and install package (Unix)
7373
if: runner.os != 'Windows'
7474
run: |
75-
python -m pip install -ve .[braket,revkit,test,qiskit,pyparsing]
75+
python -m pip install -ve .[braket,revkit,test,qiskit,pyparsing]
7676
7777
- name: Build and install package (Windows)
7878
if: runner.os == 'Windows'
7979
run: |
80-
python -m pip install -ve .[braket,test,qiskit,pyparsing]
80+
python -m pip install -ve .[braket,test,qiskit,pyparsing]
8181
8282
- name: Pytest
8383
run: |

projectq/backends/_qasm.py

+19-27
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,40 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
""" Backend to convert ProjectQ commands to OpenQASM. """
15+
"""Backend to convert ProjectQ commands to OpenQASM."""
1616

1717
from copy import deepcopy
1818

1919
from projectq.cengines import BasicEngine
2020
from projectq.meta import get_control_count, has_negative_control
2121
from projectq.ops import (
22-
X,
2322
NOT,
24-
Y,
25-
Z,
26-
T,
27-
Tdag,
28-
S,
29-
Sdag,
23+
Allocate,
24+
Barrier,
25+
Deallocate,
26+
FlushGate,
3027
H,
28+
Measure,
3129
Ph,
3230
R,
3331
Rx,
3432
Ry,
3533
Rz,
34+
S,
35+
Sdag,
3636
Swap,
37-
Measure,
38-
Allocate,
39-
Deallocate,
40-
Barrier,
41-
FlushGate,
37+
T,
38+
Tdag,
39+
X,
40+
Y,
41+
Z,
4242
)
4343

44-
4544
# ==============================================================================
4645

4746

4847
class OpenQASMBackend(BasicEngine): # pylint: disable=too-many-instance-attributes
49-
"""
50-
Engine to convert ProjectQ commands to OpenQASM format (either string or file)
51-
"""
48+
"""Engine to convert ProjectQ commands to OpenQASM format (either string or file)."""
5249

5350
def __init__(
5451
self,
@@ -87,18 +84,16 @@ def __init__(
8784
self._qubit_id_mapping_redux = qubit_id_mapping_redux
8885

8986
self._output = []
90-
self._qreg_dict = dict()
91-
self._creg_dict = dict()
87+
self._qreg_dict = {}
88+
self._creg_dict = {}
9289
self._reg_index = 0
9390
self._available_indices = []
9491

9592
self._insert_openqasm_header()
9693

9794
@property
9895
def qasm(self):
99-
"""
100-
Access to the QASM representation of the circuit.
101-
"""
96+
"""Access to the QASM representation of the circuit."""
10297
return self._output
10398

10499
def is_available(self, cmd):
@@ -146,8 +141,7 @@ def is_available(self, cmd):
146141

147142
def receive(self, command_list):
148143
"""
149-
Receives a command list and, for each command, stores it until
150-
completion.
144+
Receives a command list and, for each command, stores it until completion.
151145
152146
Args:
153147
command_list: List of commands to execute
@@ -309,9 +303,7 @@ def _insert_openqasm_header(self):
309303
self._output.append('include "stdgates.inc";')
310304

311305
def _reset_after_flush(self):
312-
"""
313-
Reset the internal quantum circuit after a FlushGate
314-
"""
306+
"""Reset the internal quantum circuit after a FlushGate."""
315307
if not self._collate_callback:
316308
self._output.append('# ' + '=' * 80)
317309
else:

projectq/backends/_qasm_test.py

+18-16
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,37 @@
1414
# limitations under the License.
1515
"""Tests for projectq.cengines._openqasm.py."""
1616

17+
import re
18+
1719
import pytest
1820

19-
import re
20-
from projectq.cengines import MainEngine, DummyEngine
21+
from projectq.cengines import DummyEngine, MainEngine
2122
from projectq.meta import Control
2223
from projectq.ops import (
23-
X,
2424
NOT,
25-
Y,
26-
Z,
27-
T,
28-
Tdagger,
29-
S,
30-
Sdagger,
25+
All,
26+
Allocate,
27+
Barrier,
28+
Command,
29+
Deallocate,
30+
Entangle,
3131
H,
32+
Measure,
3233
Ph,
3334
R,
3435
Rx,
3536
Ry,
3637
Rz,
37-
Allocate,
38-
Deallocate,
39-
Measure,
40-
Barrier,
41-
Entangle,
42-
Command,
43-
All,
38+
S,
39+
Sdagger,
40+
T,
41+
Tdagger,
42+
X,
43+
Y,
44+
Z,
4445
)
4546
from projectq.types import WeakQubitRef
47+
4648
from ._qasm import OpenQASMBackend
4749

4850
# ==============================================================================

0 commit comments

Comments
 (0)