Browse Source

Remove match_multiply_zero in favor of match_multiply_numerics.

Sander Mathijs van Veen 13 năm trước cách đây
mục cha
commit
e463573b19
2 tập tin đã thay đổi với 3 bổ sung23 xóa
  1. 3 4
      src/rules/__init__.py
  2. 0 19
      src/rules/numerics.py

+ 3 - 4
src/rules/__init__.py

@@ -8,7 +8,7 @@ from .powers import match_add_exponents, match_subtract_exponents, \
         match_raised_fraction, match_remove_negative_exponent, \
         match_exponent_to_root, match_extend_exponent, match_constant_exponent
 from .numerics import match_add_numerics, match_divide_numerics, \
-        match_multiply_numerics, match_multiply_zero, match_raise_numerics
+        match_multiply_numerics, match_raise_numerics
 from .fractions import match_constant_division, match_add_fractions, \
         match_multiply_fractions, match_divide_fractions, \
         match_extract_fraction_terms, match_division_in_denominator
@@ -38,9 +38,8 @@ RULES = {
                  match_combine_groups, match_add_quadrants,
                  match_add_logarithms, match_sort_polynome],
         OP_MUL: [match_multiply_numerics, match_expand, match_add_exponents,
-                 match_multiply_zero, match_negated_factor,
-                 match_multiply_fractions, match_factor_in_multiplicant,
-                 match_sort_monomial],
+                 match_negated_factor, match_multiply_fractions,
+                 match_factor_in_multiplicant, match_sort_monomial],
         OP_DIV: [match_subtract_exponents, match_divide_numerics,
                  match_constant_division, match_divide_fractions,
                  match_negated_division, match_extract_fraction_terms,

+ 0 - 19
src/rules/numerics.py

@@ -165,25 +165,6 @@ MESSAGES[reduce_fraction_constants] = \
         _('Divide the nominator and denominator of fraction {0} by {1}.')
 
 
-def match_multiply_zero(node):
-    """
-    a * 0    ->  0
-    0 * a    ->  0
-    -0 * a   ->  -0
-    0 * -a   ->  -0
-    -0 * -a  ->  0
-    """
-    assert node.is_op(OP_MUL)
-
-    left, right = node
-
-    if (left.is_leaf and left.value == 0) \
-            or (right.is_leaf and right.value == 0):
-        return [P(node, multiply_zero, (left.negated + right.negated,))]
-
-    return []
-
-
 def match_multiply_numerics(node):
     """
     3 * 2      ->  6