ソースを参照

Added message for raised_base rule, and added it to src/rules/__init__.py.

Taddeus Kroes 14 年 前
コミット
a9885848df
3 ファイル変更10 行追加2 行削除
  1. 3 2
      src/rules/__init__.py
  2. 3 0
      src/rules/logarithmic.py
  3. 4 0
      tests/test_rules_logarithmic.py

+ 3 - 2
src/rules/__init__.py

@@ -22,7 +22,7 @@ from src.rules.derivatives import match_zero_derivative, \
         match_const_deriv_multiplication, match_logarithmic, \
         match_goniometric, match_sum_product_rule, match_quotient_rule
 from src.rules.logarithmic import match_constant_logarithm, \
-        match_add_logarithms
+        match_add_logarithms, match_raised_base
 
 RULES = {
         OP_ADD: [match_add_numerics, match_add_constant_fractions,
@@ -38,7 +38,8 @@ RULES = {
         OP_POW: [match_multiply_exponents, match_duplicate_exponent,
                  match_raised_fraction, match_remove_negative_exponent,
                  match_exponent_to_root, match_extend_exponent,
-                 match_constant_exponent, match_raise_numerics],
+                 match_constant_exponent, match_raise_numerics,
+                 match_raised_base],
         OP_NEG: [match_negate_polynome],
         OP_SIN: [match_negated_parameter, match_half_pi_subtraction,
                  match_standard_radian],

+ 3 - 0
src/rules/logarithmic.py

@@ -175,3 +175,6 @@ def raised_base(root, args):
     g ^ log_g(a)  ->  a
     """
     return args[0]
+
+
+MESSAGES[raised_base] = _('Apply g ^ log_g(a) = a on {0}.')

+ 4 - 0
tests/test_rules_logarithmic.py

@@ -80,6 +80,10 @@ class TestRulesLogarithmic(RulesTestCase):
         self.assertEqualPos(match_raised_base(root),
                 [P(root, raised_base, (a,))])
 
+        root, a = tree('e ^ ln(a), a')
+        self.assertEqualPos(match_raised_base(root),
+                [P(root, raised_base, (a,))])
+
         root = tree('2 ^ log_3(a)')
         self.assertEqualPos(match_raised_base(root), [])