Просмотр исходного кода

Slightly tweaked a fraction rule.

Taddeus Kroes 14 лет назад
Родитель
Сommit
5a1c1bc23d
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      src/rules/fractions.py

+ 3 - 3
src/rules/fractions.py

@@ -179,8 +179,8 @@ MESSAGES[constant_to_fraction] = \
 
 def match_multiply_fractions(node):
     """
-    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 / d  ->  (ac) / (bd)
+    a / b * c and (eval(c) in Z or eval(a / b) not in Z)  ->  (ac) / b
     """
     assert node.is_op(OP_MUL)
 
@@ -192,7 +192,7 @@ def match_multiply_fractions(node):
         p.append(P(node, multiply_fractions, (scope, ab, cd)))
 
     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)))
 
     return p