Explorar el Código

Fixed missing import and fixed negative multiplication

Sander Mathijs van Veen hace 14 años
padre
commit
e32aa00ce2
Se han modificado 2 ficheros con 3 adiciones y 3 borrados
  1. 2 2
      src/rules/__init__.py
  2. 1 1
      src/rules/numerics.py

+ 2 - 2
src/rules/__init__.py

@@ -5,7 +5,7 @@ from .factors import match_expand
 from .powers import match_add_exponents, match_subtract_exponents, \
         match_multiply_exponents, match_duplicate_exponent, \
         match_remove_negative_exponent, match_exponent_to_root
-from .numerics import match_divide_numerics
+from .numerics import match_divide_numerics, match_multiply_numerics
 from .fractions import match_constant_division, match_add_constant_fractions, \
         match_expand_and_add_fractions
 
@@ -13,7 +13,7 @@ from .fractions import match_constant_division, match_add_constant_fractions, \
 RULES = {
         OP_ADD: [match_add_constant_fractions, match_combine_polynomes, \
                  match_combine_groups],
-        OP_MUL: [match_expand, match_add_exponents, \
+        OP_MUL: [match_multiply_numerics, match_expand, match_add_exponents, \
                  match_expand_and_add_fractions],
         OP_DIV: [match_subtract_exponents, match_divide_numerics, \
                  match_constant_division],

+ 1 - 1
src/rules/numerics.py

@@ -123,7 +123,7 @@ def match_multiply_numerics(node):
         if n.is_numeric():
             numerics.append((n, n.value))
         elif n.is_op(OP_NEG) and n[0].is_numeric():
-            numerics.append((n, n[0].value))
+            numerics.append((n, -n[0].value))
 
     for (n0, v0), (n1, v1) in combinations(numerics, 2):
         p.append(P(node, multiply_numerics, (n0, n1, v0, v1)))