Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dakk committed Nov 15, 2023
1 parent b1f0bb3 commit b2737ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion qlasskit/ast2logic/t_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def unfold(v_exps, op):
args_v = [b for (a, b) in args]

q_gate = QuantumBooleanGate.build(gate)

if len(args_v) == 1 and isinstance(args_v[0], list):
return args[0][0], [q_gate(a) for a in args_v[0]]
else:
Expand Down
17 changes: 15 additions & 2 deletions qlasskit/boolquant.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
from copy import deepcopy
# Copyright 2023 Davide Gessa

# 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 sympy import Function
from sympy.logic.boolalg import Boolean


class QuantumBooleanGate(Function, Boolean):
def build(name: str):
return type(name, (QuantumBooleanGate,), { })
return type(name, (QuantumBooleanGate,), {})


class Q:
Expand Down
2 changes: 1 addition & 1 deletion qlasskit/compiler/internalcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def compile_expr( # noqa: C901
elif isinstance(expr, QuantumBooleanGate):
erets = list(map(lambda e: self.compile_expr(qc, e), expr.args)) # type: ignore
gate = expr.__class__.__name__.lower()

if hasattr(qc, gate):
if gate[0] == "m":
getattr(qc, gate)(erets[0:-1], erets[-1])
Expand Down

0 comments on commit b2737ce

Please sign in to comment.