Commit 5a1c1bc2 authored by Taddeus Kroes's avatar Taddeus Kroes

Slightly tweaked a fraction rule.

parent 104b353c
...@@ -179,8 +179,8 @@ MESSAGES[constant_to_fraction] = \ ...@@ -179,8 +179,8 @@ MESSAGES[constant_to_fraction] = \
def match_multiply_fractions(node): def match_multiply_fractions(node):
""" """
a / b * (c / d) -> ac / (bd) a / b * c / d -> (ac) / (bd)
a / b * c and (c in Z or eval(a / b) not in Z) -> ac / b a / b * c and (eval(c) in Z or eval(a / b) not in Z) -> (ac) / b
""" """
assert node.is_op(OP_MUL) assert node.is_op(OP_MUL)
...@@ -192,7 +192,7 @@ def match_multiply_fractions(node): ...@@ -192,7 +192,7 @@ def match_multiply_fractions(node):
p.append(P(node, multiply_fractions, (scope, ab, cd))) p.append(P(node, multiply_fractions, (scope, ab, cd)))
for ab, c in product(fractions, others): for ab, c in product(fractions, others):
if c.is_numeric() or not evals_to_numeric(ab): if evals_to_numeric(c) or not evals_to_numeric(ab):
p.append(P(node, multiply_with_fraction, (scope, ab, c))) p.append(P(node, multiply_with_fraction, (scope, ab, c)))
return p return p
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment