当前位置: 首页>>代码示例>>Python>>正文


Python Expr.matches方法代码示例

本文整理汇总了Python中expr.Expr.matches方法的典型用法代码示例。如果您正苦于以下问题:Python Expr.matches方法的具体用法?Python Expr.matches怎么用?Python Expr.matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在expr.Expr的用法示例。


在下文中一共展示了Expr.matches方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: matches

# 需要导入模块: from expr import Expr [as 别名]
# 或者: from expr.Expr import matches [as 别名]
    def matches(self, expr, repl_dict={}, old=False):
        expr = _sympify(expr)

        # special case, pattern = 1 and expr.exp can match to 0
        if expr is S.One:
            d = repl_dict.copy()
            d = self.exp.matches(S.Zero, d)
            if d is not None:
                return d

        b, e = expr.as_base_exp()

        # special case number
        sb, se = self.as_base_exp()
        if sb.is_Symbol and se.is_Integer and expr:
            if e.is_rational:
                return sb.matches(b**(e/se), repl_dict)
            return sb.matches(expr**(1/se), repl_dict)

        d = repl_dict.copy()
        d = self.base.matches(b, d)
        if d is None:
            return None

        d = self.exp.xreplace(d).matches(e, d)
        if d is None:
            return Expr.matches(self, expr, repl_dict)
        return d
开发者ID:Maihj,项目名称:sympy,代码行数:30,代码来源:power.py

示例2: matches

# 需要导入模块: from expr import Expr [as 别名]
# 或者: from expr.Expr import matches [as 别名]
 def matches(self, expr, repl_dict={}, evaluate=False):
     if self in repl_dict:
         if repl_dict[self] == expr:
             return repl_dict
     elif isinstance(expr, Derivative):
         if len(expr.variables) == len(self.variables):
             return Expr.matches(self, expr, repl_dict, evaluate)
开发者ID:addisonc,项目名称:sympy,代码行数:9,代码来源:function.py

示例3: matches

# 需要导入模块: from expr import Expr [as 别名]
# 或者: from expr.Expr import matches [as 别名]
    def matches(self, expr, repl_dict={}):
        expr = _sympify(expr)
        b, e = expr.as_base_exp()

        # special case, pattern = 1 and expr.exp can match to 0
        if expr is S.One:
            d = repl_dict.copy()
            d = self.exp.matches(S.Zero, d)
            if d is not None:
                return d

        d = repl_dict.copy()
        d = self.base.matches(b, d)
        if d is None:
            return None

        d = self.exp.xreplace(d).matches(e, d)
        if d is None:
            return Expr.matches(self, expr, repl_dict)
        return d
开发者ID:itsrg,项目名称:sympy,代码行数:22,代码来源:power.py

示例4: matches

# 需要导入模块: from expr import Expr [as 别名]
# 或者: from expr.Expr import matches [as 别名]
    def matches(self, expr, repl_dict={}, evaluate=False):
        # this method needs a cleanup.

        if self in repl_dict:
            if repl_dict[self] == expr:
                return repl_dict
            else:
                return None
        if isinstance(expr, Derivative):
            if len(expr.symbols) == len(self.symbols):
                    #print "MAYBE:",self, expr, repl_dict, evaluate
                return Expr.matches(self, expr, repl_dict, evaluate)
        #print "NONE:",self, expr, repl_dict, evaluate
        return None
        #print self, expr, repl_dict, evaluate
        stop
        if self.nargs is not None:
            if self.nargs != expr.nargs:
                return None
        repl_dict = repl_dict.copy()
        repl_dict[self] = expr
        return repl_dict
开发者ID:goriccardo,项目名称:sympy,代码行数:24,代码来源:function.py

示例5: matches

# 需要导入模块: from expr import Expr [as 别名]
# 或者: from expr.Expr import matches [as 别名]
    def matches(self, expr, repl_dict={}, evaluate=False):
        if evaluate:
            return self.subs(repl_dict).matches(expr, repl_dict)

        expr = _sympify(expr)
        b, e = expr.as_base_exp()

        # special case, pattern = 1 and expr.exp can match to 0
        if expr is S.One:
            d = repl_dict.copy()
            d = self.exp.matches(S.Zero, d)
            if d is not None:
                return d

        d = repl_dict.copy()
        d = self.base.matches(b, d)
        if d is None:
            return None

        d = self.exp.subs(d).matches(e, d)
        if d is None:
            return Expr.matches(self, expr, repl_dict, evaluate)
        return d
开发者ID:Aang,项目名称:sympy,代码行数:25,代码来源:power.py


注:本文中的expr.Expr.matches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。