• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python rulestestcase.tree函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python run.Session类代码示例发布时间:2022-05-27
下一篇:
Python base.Base类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap