Closed aaditya-panik closed 3 years ago
Yeah you're right, this looks like a bug introduced in 3.0 when the change to using Decimal took place. The math.pow
function returns a native float
instance instead of a decimal.Decimal
instance so it should be updated with the operator.pow
as you suggested in the ArithmeticExpression` class..
Thanks for catching this. I'll put together a patch later today.
Fixed in commit e229063be8e53f6de9790a66354a75d24510e640 which has been released in v3.1.2 and pushed to PyPi.
Hi @zeroSteiner
I was going through some expressions and noticed something for arithmetic expressions using powers. The parser parses powers as a
float
type (mostly because it uses themath.pow
method) versus other operators which which result indecimal.Decimal
.https://github.com/zeroSteiner/rule-engine/blob/7a48664ddbfabf7a8aa9b544eab0e9eccda029e0/lib/rule_engine/ast.py#L779
this results in
TypeError: unsupported operand type(s) for /: 'decimal.Decimal' and 'float'
.I think this can be resolved by using
operator.pow
instead ofmath.pow
.To recreate the error,