Skip to content

Commit 9212f38

Browse files
committed
Added rule to check if MathExpr is a constant
1 parent 1e5c5d8 commit 9212f38

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/oqd_core/compiler/math/rules.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,3 +408,15 @@ def map_MathDiv(self, model: MathDiv, operands):
408408

409409
def map_MathPow(self, model: MathPow, operands):
410410
return operands["expr1"] ** operands["expr2"]
411+
412+
413+
########################################################################################
414+
415+
416+
class IsConstant(RewriteRule):
417+
def map_MathExpr(self, model):
418+
if getattr(self, "isconstant", None) is None:
419+
self.isconstant = True
420+
421+
def map_MathVar(self, model):
422+
self.isconstant = False

0 commit comments

Comments
 (0)