本文整理汇总了Python中tests.rulestestcase.tree函数的典型用法代码示例。如果您正苦于以下问题:Python tree函数的具体用法?Python tree怎么用?Python tree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tree函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_match_quotient_rule
def test_match_quotient_rule(self):
root = tree('d/dx x ^ 2 / x')
self.assertEqualPos(match_quotient_rule(root),
[P(root, quotient_rule)])
root = tree('d/dx x ^ 2 / 2')
self.assertEqualPos(match_quotient_rule(root), [])
开发者ID:smvv,项目名称:trs,代码行数:7,代码来源:test_rules_derivatives.py
示例2: test_add_quadrants
def test_add_quadrants(self):
s, c = root = tree('sin(t) ^ 2 + cos(t) ^ 2')
self.assertEqual(add_quadrants(root, (Scope(root), s, c)), 1)
root, expect = tree('cos(t) ^ 2 + a + sin(t) ^ 2, a + 1')
(c, a), s = root
self.assertEqual(add_quadrants(root, (Scope(root), s, c)), expect)
开发者ID:smvv,项目名称:trs,代码行数:7,代码来源:test_rules_goniometry.py
示例3: test_match_sort_monomial_constant
def test_match_sort_monomial_constant(self):
x, l2 = root = tree('x * 2')
self.assertEqualPos(match_sort_monomial(root),
[P(root, swap_factors, (Scope(root), x, l2))])
root = tree('2x')
self.assertEqualPos(match_sort_monomial(root), [])
开发者ID:smvv,项目名称:trs,代码行数:7,代码来源:test_rules_sort.py
示例4: test_match_sort_polynome
def test_match_sort_polynome(self):
x, x2 = root = tree('x + x ^ 2')
self.assertEqualPos(match_sort_polynome(root),
[P(root, swap_factors, (Scope(root), x, x2))])
root = tree('x + 2')
self.assertEqualPos(match_sort_polynome(root), [])
开发者ID:smvv,项目名称:trs,代码行数:7,代码来源:test_rules_sort.py
示例5: test_match_sort_monomial_variables
def test_match_sort_monomial_variables(self):
y, x = root = tree('yx')
self.assertEqualPos(match_sort_monomial(root),
[P(root, swap_factors, (Scope(root), y, x))])
root = tree('xy')
self.assertEqualPos(match_sort_monomial(root), [])
开发者ID:smvv,项目名称:trs,代码行数:7,代码来源:test_rules_sort.py
示例6: test_negated_factor
def test_negated_factor(self):
a, b = root = tree('a * -b')
self.assertEqual(negated_factor(root, (Scope(root), b)), -(a * +b))
(a, b), c = root = tree('a * (-b) * -c')
self.assertEqual(negated_factor(root, (Scope(root), b)), -(a * +b * c))
self.assertEqual(negated_factor(root, (Scope(root), c)), -(a * b * +c))
开发者ID:smvv,项目名称:trs,代码行数:7,代码来源:test_rules_negation.py
示例7: test_extract_nominator_term
def test_extract_nominator_term(self):
root, expect = tree('(2a) / 3, 2 / 3 * a')
l2, a = root[0]
self.assertEqual(extract_nominator_term(root, (l2, a)), expect)
root, expect, l1 = tree('a / 3, 1 / 3 * a, 1')
self.assertEqual(extract_nominator_term(root, (l1, root[0])), expect)
开发者ID:smvv,项目名称:trs,代码行数:7,代码来源:test_rules_fractions.py
示例8: test_match_factor_out_abs_term_exponent
def test_match_factor_out_abs_term_exponent(self):
root = tree('|a ^ 2|')
self.assertEqualPos(match_factor_out_abs_term(root),
[P(root, factor_out_abs_exponent)])
root = tree('|a ^ b|')
self.assertEqualPos(match_factor_out_abs_term(root), [])
开发者ID:smvv,项目名称:trs,代码行数:7,代码来源:test_rules_absolute.py
示例9: test_match_expand
def test_match_expand(self):
a, bc, d = tree('a,b + c,d')
b, c = bc
root = a * bc
self.assertEqualPos(match_expand(root),
[P(root, expand_single, (Scope(root), a, bc))])
root = bc * a
self.assertEqualPos(match_expand(root),
[P(root, expand_single, (Scope(root), bc, a))])
root = a * bc * d
self.assertEqualPos(match_expand(root),
[P(root, expand_single, (Scope(root), a, bc)),
P(root, expand_single, (Scope(root), bc, d))])
ab, cd = root = (a + b) * (c + d)
self.assertEqualPos(match_expand(root),
[P(root, expand_double, (Scope(root), ab, cd))])
(ab, cd), e = root = tree('(a + b)(c + d)e')
self.assertEqualPos(match_expand(root),
[P(root, expand_double, (Scope(root), ab, cd)),
P(root, expand_single, (Scope(root), cd, e)),
P(root, expand_single, (Scope(root), ab, e))])
开发者ID:smvv,项目名称:trs,代码行数:26,代码来源:test_rules_factors.py
示例10: test_match_factor_out_abs_term_numeric
def test_match_factor_out_abs_term_numeric(self):
root = tree('|2|')
self.assertEqualPos(match_factor_out_abs_term(root),
[P(root, absolute_numeric)])
root = tree('|a|')
self.assertEqualPos(match_factor_out_abs_term(root), [])
开发者ID:smvv,项目名称:trs,代码行数:7,代码来源:test_rules_absolute.py
示例11: test_match_remove_division_negation
def test_match_remove_division_negation(self):
root = tree('-(-a + b) / c')
self.assertEqualPos(match_remove_division_negation(root),
[P(root, remove_division_negation, (True, root[0]))])
root = tree('-a / (-b + c)')
self.assertEqualPos(match_remove_division_negation(root),
[P(root, remove_division_negation, (False, root[1]))])
开发者ID:smvv,项目名称:trs,代码行数:8,代码来源:test_rules_fractions.py
示例12: test_match_division_in_denominator
def test_match_division_in_denominator(self):
a, ((b, c), d) = root = tree('a / (b / c + d)')
self.assertEqualPos(match_division_in_denominator(root),
[P(root, multiply_with_term, (c,))])
a, ((d, (b, c)), e) = root = tree('a / (d + b / c + e)')
self.assertEqualPos(match_division_in_denominator(root),
[P(root, multiply_with_term, (c,))])
开发者ID:smvv,项目名称:trs,代码行数:8,代码来源:test_rules_fractions.py
示例13: test_match_exponent_to_root
def test_match_exponent_to_root(self):
root = tree('a ^ (1 / 2)')
self.assertEqualPos(match_exponent_to_root(root),
[P(root, exponent_to_root)])
root = tree('a ^ (n / 2)')
self.assertEqualPos(match_exponent_to_root(root),
[P(root, exponent_to_root)])
开发者ID:smvv,项目名称:trs,代码行数:8,代码来源:test_rules_powers.py
示例14: test_match_goniometric_chain_rule
def test_match_goniometric_chain_rule(self):
root, x2 = tree('d/dx sin(x ^ 2), x ^ 2')
self.assertEqualPos(match_goniometric(root),
[P(root, chain_rule, (x2, sinus, ()))])
root = tree('d/dx cos(x ^ 2)')
self.assertEqualPos(match_goniometric(root),
[P(root, chain_rule, (x2, cosinus, ()))])
开发者ID:smvv,项目名称:trs,代码行数:8,代码来源:test_rules_derivatives.py
示例15: test_match_one_derivative
def test_match_one_derivative(self):
root = tree('d/dx x')
self.assertEqualPos(match_one_derivative(root),
[P(root, one_derivative)])
root = tree('d/dx x')
self.assertEqualPos(match_one_derivative(root),
[P(root, one_derivative)])
开发者ID:smvv,项目名称:trs,代码行数:8,代码来源:test_rules_derivatives.py
示例16: test_multiply_fractions
def test_multiply_fractions(self):
(a, b), (c, d) = ab, cd = root = tree('a / b * (c / d)')
self.assertEqual(multiply_fractions(root, (Scope(root), ab, cd)),
a * c / (b * d))
(ab, e), cd = root = tree('a / b * e * (c / d)')
self.assertEqual(multiply_fractions(root, (Scope(root), ab, cd)),
a * c / (b * d) * e)
开发者ID:smvv,项目名称:trs,代码行数:8,代码来源:test_rules_fractions.py
示例17: test_remove_division_negation
def test_remove_division_negation(self):
(a, b), c = root = tree('-(-a + b) / c')
self.assertEqual(remove_division_negation(root, (True, root[0])),
(-a - b) / c)
a, (b, c) = root = tree('-a / (-b + c)')
self.assertEqual(remove_division_negation(root, (False, root[1])),
+a / (-b - c))
开发者ID:smvv,项目名称:trs,代码行数:8,代码来源:test_rules_fractions.py
示例18: test_match_reduce_sqrt_dividers
def test_match_reduce_sqrt_dividers(self):
root = tree('sqrt(8)')
self.assertEqualPos(match_reduce_sqrt(root),
[P(root, split_dividers, (4, 2))])
root = tree('sqrt(27)')
self.assertEqualPos(match_reduce_sqrt(root),
[P(root, split_dividers, (9, 3))])
开发者ID:smvv,项目名称:trs,代码行数:8,代码来源:test_rules_sqrt.py
示例19: test_sum_rule_integral
def test_sum_rule_integral(self):
((f, g), h), x = root = tree('int (2x + 3x + 4x) dx')
self.assertEqual(sum_rule_integral(root, (Scope(root[0]), f)),
tree('int 2x dx + int (3x + 4x) dx'))
self.assertEqual(sum_rule_integral(root, (Scope(root[0]), g)),
tree('int 3x dx + int (2x + 4x) dx'))
self.assertEqual(sum_rule_integral(root, (Scope(root[0]), h)),
tree('int 4x dx + int (2x + 3x) dx'))
开发者ID:smvv,项目名称:trs,代码行数:8,代码来源:test_rules_integrals.py
示例20: test_match_factor_out_constant
def test_match_factor_out_constant(self):
root, c, cx = tree('int cx dx, c, cx')
self.assertEqualPos(match_factor_out_constant(root),
[P(root, factor_out_constant, (Scope(cx), c))])
root = tree('int -x2 dx')
self.assertEqualPos(match_factor_out_constant(root),
[P(root, factor_out_integral_negation)])
开发者ID:smvv,项目名称:trs,代码行数:8,代码来源:test_rules_integrals.py
注:本文中的tests.rulestestcase.tree函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论