Skip to content

Commit

Permalink
Fix linting errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
elenbaasc committed May 3, 2024
1 parent 3e41890 commit 66bcf01
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions opensquirrel/circuit_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CircuitBuilder(GateLibrary, MeasurementLibrary):
<BLANKLINE>
"""

def __init__(
self,
number_of_qubits: int,
Expand All @@ -43,9 +44,7 @@ def __init__(
):
GateLibrary.__init__(self, gate_set, gate_aliases)
MeasurementLibrary.__init__(self, measurement_set)
self.squirrel_ir = SquirrelIR(
number_of_qubits=number_of_qubits, qubit_register_name="q"
)
self.squirrel_ir = SquirrelIR(number_of_qubits=number_of_qubits, qubit_register_name="q")

def __getattr__(self, attr):
def add_comment(comment_string: str):
Expand All @@ -68,7 +67,8 @@ def _check_generator_f_args(generator_f, args):
if not isinstance(args[i], par.annotation):
raise TypeError(
f"Wrong argument type for instruction `{attr}`, got {type(args[i])} but expected"
f" {par.annotation}")
f" {par.annotation}"
)

return add_comment if attr == "comment" else add_instruction

Expand Down
3 changes: 2 additions & 1 deletion opensquirrel/exporter/quantify_scheduler_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
BlochSphereRotation,
ControlledGate,
MatrixGate,
Measure,
Qubit,
SquirrelIR,
SquirrelIRVisitor, Measure,
SquirrelIRVisitor,
)

try:
Expand Down
3 changes: 1 addition & 2 deletions test/exporter/test_quantify_scheduler_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from opensquirrel.common import ATOL
from opensquirrel.default_gates import CCZ, CZ, SWAP, H, Ry, Rz, X
from opensquirrel.exporter import quantify_scheduler_exporter
from opensquirrel.squirrel_ir import BlochSphereRotation, Float, Gate, Qubit, SquirrelIR, Measure
from opensquirrel.squirrel_ir import BlochSphereRotation, Float, Gate, Measure, Qubit, SquirrelIR


class FloatEq(float):
Expand Down Expand Up @@ -47,7 +47,6 @@ def test_export(self):
squirrel_ir.add_measurement(Measure(Qubit(1)))
squirrel_ir.add_measurement(Measure(Qubit(2)))


with MockedQuantifyScheduler() as (mock_quantify_scheduler, mock_quantify_scheduler_gates):
mock_schedule = unittest.mock.MagicMock()
mock_quantify_scheduler.Schedule.return_value = mock_schedule
Expand Down
11 changes: 7 additions & 4 deletions test/test_circuit_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest

from opensquirrel.circuit_builder import CircuitBuilder
from opensquirrel.default_gates import H, CNOT
from opensquirrel.squirrel_ir import Qubit, Measure, Comment
from opensquirrel.default_gates import CNOT, H
from opensquirrel.squirrel_ir import Comment, Measure, Qubit


class TestCircuitBuilder:
Expand Down Expand Up @@ -85,5 +85,8 @@ def test_wrong_argument_type(self):

with pytest.raises(Exception) as exception_info:
builder.H(0)
assert re.search("Wrong argument type for instruction `H`, got <class 'int'> but expected <class "
"'opensquirrel.squirrel_ir.Qubit'>", str(exception_info.value))
assert re.search(
"Wrong argument type for instruction `H`, got <class 'int'> but expected <class "
"'opensquirrel.squirrel_ir.Qubit'>",
str(exception_info.value),
)

0 comments on commit 66bcf01

Please sign in to comment.