Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
dakk committed Oct 26, 2023
1 parent 9cd1dc9 commit 8d721c2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions examples/ex1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

INTSIZ = 2


@qlassf
def f1(b: bool, n: Qint2) -> Qint2:
return n + (1 if b else 2)


@qlassf
def f_comp(b: bool, n: Qint2) -> Qint2:
for i in range(3):
n += (1 if b else 2)
n += 1 if b else 2
return n


Expand All @@ -25,11 +27,11 @@ def f_comp(b: bool, n: Qint2) -> Qint2:


gate1 = f1.gate()
qc = QuantumCircuit(gate.num_qubits*3)
qc = QuantumCircuit(gate.num_qubits * 3)

for i in range(3):
qc.barrier(label="=")
qc.append(gate1, [0] + list(range(1+i * INTSIZ, 1+i*INTSIZ+INTSIZ*2)))
qc.append(gate1, [0] + list(range(1 + i * INTSIZ, 1 + i * INTSIZ + INTSIZ * 2)))

print(qc.decompose().draw("text"))
print(qc.decompose().count_ops())
2 changes: 1 addition & 1 deletion qlasskit/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from sympy import Symbol
from sympy.logic import ITE, And, Implies, Not, Or, Xor
from sympy.logic.boolalg import Boolean, BooleanFalse, BooleanTrue #, to_anf
from sympy.logic.boolalg import Boolean, BooleanFalse, BooleanTrue # , to_anf

from .. import QCircuit
from ..ast2logic.typing import Arg, Args, BoolExpList
Expand Down
4 changes: 3 additions & 1 deletion qlasskit/compiler/tweedledumcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def twcircuit_to_qcircuit(twc):
class TweedledumCompiler(Compiler):
"""Compile using tweedledum synthesis library"""

def compile(self, name, args: Args, returns: Arg, exprs: BoolExpList) -> QCircuit: # noqa: C901
def compile( # noqa: C901
self, name, args: Args, returns: Arg, exprs: BoolExpList
) -> QCircuit:
exprs = [(symb, self._symplify_exp(exp)) for symb, exp in exprs]
_logic_network = sympy_to_logic_network(name, args, returns, exprs)

Expand Down
2 changes: 1 addition & 1 deletion test/test_qlassf_for_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_for_1it(self):
f = "def test(a: Qint2) -> Qint2:\n\tfor x in range(1):\n\t\ta += 1\n\treturn a"
qf = qlassf(f, to_compile=COMPILATION_ENABLED)
compute_and_compare_results(self, qf)

def test_for_4it(self):
f = "def test(a: Qint2) -> Qint2:\n\tfor x in range(4):\n\t\ta += 1\n\treturn a"
qf = qlassf(f, to_compile=COMPILATION_ENABLED)
Expand Down

0 comments on commit 8d721c2

Please sign in to comment.