Skip to content

Commit e229063

Browse files
committed
Use operator.pow instead of math.pow for the decimal.Decimal objects
1 parent 7a48664 commit e229063

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/rule_engine/ast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ def __op_arithmetic(self, op, thing):
776776
_op_tdiv = functools.partialmethod(__op_arithmetic, operator.truediv)
777777
_op_mod = functools.partialmethod(__op_arithmetic, operator.mod)
778778
_op_mul = functools.partialmethod(__op_arithmetic, operator.mul)
779-
_op_pow = functools.partialmethod(__op_arithmetic, math.pow)
779+
_op_pow = functools.partialmethod(__op_arithmetic, operator.pow)
780780

781781
class BitwiseExpression(LeftOperatorRightExpressionBase):
782782
"""

tests/issues.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,7 @@ def test_number_19(self):
7272
)
7373
rule = engine.Rule('facts.abc == "def"', context=context)
7474
self.assertTrue(rule.matches({'facts': {'abc': 'def'}}))
75+
76+
def test_number_20(self):
77+
rule = engine.Rule('a / b ** 2')
78+
self.assertEqual(rule.evaluate({'a': 8, 'b': 4}), 0.5)

0 commit comments

Comments
 (0)