Skip to content

Commit

Permalink
remove deprecated optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
dakk committed Nov 9, 2023
1 parent f5db491 commit 05c3b9e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 236 deletions.
1 change: 1 addition & 0 deletions qlasskit/boolopt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
# isort:skip_file

from .sympytransformer import SympyTransformer # noqa: F401
from .bool_optimizer import BoolOptimizerProfile, bestWorkingOptimizer # noqa: F401
17 changes: 1 addition & 16 deletions qlasskit/boolopt/bool_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from sympy.logic.boolalg import And, Boolean, Not, Or, Xor, simplify_logic

from ..ast2logic import BoolExpList
from . import SympyTransformer, deprecated
from . import SympyTransformer
from .exp_transformers import (
remove_Implies,
remove_ITE,
Expand Down Expand Up @@ -83,18 +83,3 @@ def apply(self, exps):
transform_or2and(),
]
)


deprecatedWorkingOptimizer = BoolOptimizerProfile(
[
deprecated.remove_const_exps,
deprecated.remove_unnecessary_assigns,
deprecated.merge_unnecessary_assigns,
merge_expressions,
apply_cse,
remove_ITE(),
remove_Implies(),
transform_or2xor(),
transform_or2and(),
]
)
144 changes: 0 additions & 144 deletions qlasskit/boolopt/deprecated.py

This file was deleted.

12 changes: 9 additions & 3 deletions qlasskit/qlassf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from .ast2ast import ast2ast
from .ast2logic import Arg, Args, BoolExpList, LogicFun, flatten, translate_ast
from .boolopt.bool_optimizer import bestWorkingOptimizer
from .boolopt import BoolOptimizerProfile, bestWorkingOptimizer
from .compiler import SupportedCompiler, to_quantum
from .types import * # noqa: F403, F401
from .types import Qtype, type_repr
Expand Down Expand Up @@ -180,6 +180,7 @@ def from_function(
defs: List[LogicFun] = [],
to_compile: bool = True,
compiler: SupportedCompiler = "internal",
bool_optimizer: BoolOptimizerProfile = bestWorkingOptimizer,
) -> "QlassF":
"""Create a QlassF from a function or a string containing a function
Expand All @@ -189,6 +190,8 @@ def from_function(
defs (List[LogicFun]): list of LogicFun to inject
to_compile (boolean, optional): if True, compile to quantum circuit (default: True)
compiler (SupportedCompiler, optional): override default compiler (default: internal)
bool_optimizer (BoolOptimizerProfile, optional): override default optimizer
(default: bestWorkingOptimizer)
"""
if isinstance(f, str):
exec(f)
Expand All @@ -199,7 +202,7 @@ def from_function(
fun_name, args, fun_ret, exps = translate_ast(fun, types, defs)
original_f = eval(fun_name) if isinstance(f, str) else f

exps = bestWorkingOptimizer.apply(exps)
exps = bool_optimizer.apply(exps)

# print(exps)

Expand All @@ -217,6 +220,7 @@ def qlassf(
defs: List[QlassF] = [],
to_compile: bool = True,
compiler: SupportedCompiler = "internal",
bool_optimizer: BoolOptimizerProfile = bestWorkingOptimizer,
) -> QlassF:
"""Decorator / function creating a QlassF object
Expand All @@ -225,7 +229,9 @@ def qlassf(
types (List[Qtype]): list of qtypes to inject
defs (List[Qlassf]): list of qlassf to inject
to_compile (boolean, optional): if True, compile to quantum circuit (default: True)
compiler (SupportedCompiler, optional): override default compiler (default: internal)
compiler (SupportedCompiler, optional): override default compiler (default: internal)
bool_optimizer (BoolOptimizerProfile, optional): override default optimizer
(default: bestWorkingOptimizer)
"""
defs_fun = list(map(lambda q: q.to_logicfun(), defs))

Expand Down
73 changes: 0 additions & 73 deletions test/test_bool_optimizer_deprecated.py

This file was deleted.

0 comments on commit 05c3b9e

Please sign in to comment.