basic.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:zippy 作者: securesystemslab 项目源码 文件源码
def canonical_variables(self):
        """Return a dictionary mapping any variable defined in
        ``self.variables`` as underscore-suffixed numbers
        corresponding to their position in ``self.variables``. Enough
        underscores are added to ensure that there will be no clash with
        existing free symbols.

        Examples
        ========

        >>> from sympy import Lambda
        >>> from sympy.abc import x
        >>> Lambda(x, 2*x).canonical_variables
        {x: 0_}
        """
        if not hasattr(self, 'variables'):
            return {}
        u = "_"
        while any(s.name.endswith(u) for s in self.free_symbols):
            u += "_"
        name = '%%i%s' % u
        V = self.variables
        return dict(list(zip(V, [C.Symbol(name % i, **v.assumptions0)
            for i, v in enumerate(V)])))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号