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

Python stringpict.prettyForm函数代码示例

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

本文整理汇总了Python中sympy.printing.pretty.stringpict.prettyForm函数的典型用法代码示例。如果您正苦于以下问题:Python prettyForm函数的具体用法?Python prettyForm怎么用?Python prettyForm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _print_contents_pretty

 def _print_contents_pretty(self, printer, *args):
     pform = self._print_operator_name_pretty(printer, *args)
     label_pform = self._print_label_pretty(printer, *args)
     label_pform = prettyForm(
         *label_pform.parens(left='(', right=')')
     )
     pform = prettyForm(*pform.right((label_pform)))
     return pform
开发者ID:ALGHeArT,项目名称:sympy,代码行数:8,代码来源:operator.py


示例2: _pretty

 def _pretty(self, printer, *args):
     from sympy.printing.pretty.stringpict import prettyForm
     pform = printer._print(self.args[0], *args)
     if printer._use_unicode:
         pform = pform**prettyForm(u'\N{DAGGER}')
     else:
         pform = pform**prettyForm('+')
     return pform
开发者ID:asmeurer,项目名称:sympy,代码行数:8,代码来源:complexes.py


示例3: _pretty

 def _pretty(self, printer, *args):
     pform_exp = printer._print(self.exp, *args)
     if printer._use_unicode:
         pform_exp = prettyForm(*pform_exp.left(prettyForm(u'\u2a02')))
     else:
         pform_exp = prettyForm(*pform_exp.left(prettyForm('x')))
     pform_base = printer._print(self.base, *args)
     return pform_base**pform_exp
开发者ID:jenshnielsen,项目名称:sympy,代码行数:8,代码来源:hilbert.py


示例4: _print_contents_pretty

 def _print_contents_pretty(self, printer, *args):
     pform = self._print_label_pretty(printer, *args)
     pform = prettyForm(*pform.left((self.lbracket_pretty)))
     pform = prettyForm(*pform.right((';')))
     nextpform = self._print_time_pretty(printer, *args)
     pform = prettyForm(*pform.right((nextpform)))
     pform = prettyForm(*pform.right((self.rbracket_pretty)))
     return pform
开发者ID:ALGHeArT,项目名称:sympy,代码行数:8,代码来源:state.py


示例5: _pretty

 def _pretty(self, printer, *args):
     pform = printer._print(self.args[0], *args)
     pform = prettyForm(*pform.right((prettyForm(','))))
     pform = prettyForm(*pform.right((printer._print(self.args[1], *args))))
     a = stringPict(u'\u03b4')
     b = pform
     top = stringPict(*b.left(' '*a.width()))
     bot = stringPict(*a.right(' '*b.width()))
     return prettyForm(binding=prettyForm.POW, *bot.below(top))
开发者ID:ArchKaine,项目名称:sympy,代码行数:9,代码来源:kronecker.py


示例6: _pretty

 def _pretty(self, printer, *args):
     from sympy.printing.pretty.stringpict import prettyForm
     # Get brackets
     pform = self._print_contents_pretty(printer, *args)
     lbracket, rbracket = self._pretty_brackets(pform.height(), printer._use_unicode)
     # Put together state
     pform = prettyForm(*pform.left(lbracket))
     pform = prettyForm(*pform.right(rbracket))
     return pform
开发者ID:BDGLunde,项目名称:sympy,代码行数:9,代码来源:state.py


示例7: _print_contents_pretty

 def _print_contents_pretty(self, printer, *args):
     if len(self.label) == 1:
         return self._print_label_pretty(printer, *args)
     else:
         pform = self._print_operator_name_pretty(printer, *args)
         label_pform = self._print_label_pretty(printer, *args)
         label_pform = prettyForm(*label_pform.parens(left="(", right=")"))
         pform = prettyForm(*pform.right((label_pform)))
         return pform
开发者ID:rouxinol,项目名称:sympsi,代码行数:9,代码来源:operator.py


示例8: _pretty

    def _pretty(self, printer, *args):
        from sympy.printing.pretty.stringpict import prettyForm

        pform = printer._print(self.args[0], *args)
        if printer._use_unicode:
            pform = pform ** prettyForm(u("\u2020"))
        else:
            pform = pform ** prettyForm("+")
        return pform
开发者ID:Bercio,项目名称:sympy,代码行数:9,代码来源:complexes.py


示例9: _print_Poly

    def _print_Poly(self, poly):
        expr = poly.as_expr()
        gens = list(poly.gens)
        domain = poly.get_domain()

        pform_head = prettyForm('Poly')
        pform_tail = self._print_seq([expr] + gens + [domain], '(', ')')

        pform = prettyForm(*pform_head.right(pform_tail))
        return pform
开发者ID:asmeurer,项目名称:scipy-2011-tutorial,代码行数:10,代码来源:pretty_poly.py


示例10: _pretty

 def _pretty(self, printer, *args):
     length = len(self.args)
     pform = printer._print("", *args)
     for i in range(length):
         next_pform = printer._print(self.args[i], *args)
         if isinstance(self.args[i], (Add, Mul)):
             next_pform = prettyForm(*next_pform.parens(left="(", right=")"))
         pform = prettyForm(*pform.right(next_pform))
         if i != length - 1:
             pform = prettyForm(*pform.right(u"\u2a02" + u" "))
     return pform
开发者ID:parleur,项目名称:sympy,代码行数:11,代码来源:tensorproduct.py


示例11: _pretty

 def _pretty(self, printer, *args):
     length = len(self.args)
     pform = printer._print('', *args)
     for i in range(length):
         next_pform = printer._print(self.args[i], *args)
         if isinstance(self.args[i], (Add, Mul)):
             next_pform = prettyForm(
                 *next_pform.parens(left='(', right=')')
             )
         pform = prettyForm(*pform.right(next_pform))
         if i != length-1:
             pform = prettyForm(*pform.right(u'\u2a02' + u' '))
     return pform
开发者ID:101man,项目名称:sympy,代码行数:13,代码来源:tensorproduct.py


示例12: _pretty

 def _pretty(self, printer, *args):
     length = len(self.args)
     pform = printer._print('', *args)
     for i in range(length):
         next_pform = printer._print(self.args[i], *args)
         if isinstance(self.args[i], (DirectSumHilbertSpace,
                       TensorProductHilbertSpace)):
             next_pform = prettyForm(
                 *next_pform.parens(left='(', right=')')
             )
         pform = prettyForm(*pform.right(next_pform))
         if i != length-1:
             pform = prettyForm(*pform.right(u' ' + u'\u2295' + u' '))
     return pform
开发者ID:ArchKaine,项目名称:sympy,代码行数:14,代码来源:hilbert.py


示例13: _pretty

 def _pretty(self, printer, *args):
     # Print state contents
     bra = self.bra._print_contents_pretty(printer, *args)
     ket = self.ket._print_contents_pretty(printer, *args)
     # Print brackets
     height = max(bra.height(), ket.height())
     use_unicode = printer._use_unicode
     lbracket, _ = self.bra._pretty_brackets(height, use_unicode)
     cbracket, rbracket = self.ket._pretty_brackets(height, use_unicode)
     # Build innerproduct
     pform = prettyForm(*bra.left(lbracket))
     pform = prettyForm(*pform.right(cbracket))
     pform = prettyForm(*pform.right(ket))
     pform = prettyForm(*pform.right(rbracket))
     return pform
开发者ID:A-turing-machine,项目名称:sympy,代码行数:15,代码来源:innerproduct.py


示例14: _print_contents_pretty

 def _print_contents_pretty(self, printer, *args):
     from sympy.printing.pretty.stringpict import prettyForm
     pform = printer._print(self.args[0], *args)
     if self.is_annihilation:
         return pform
     else:
         return pform**prettyForm(u('\u2020'))
开发者ID:B-Rich,项目名称:sympy,代码行数:7,代码来源:fermion.py


示例15: _pretty

 def _pretty(self, printer, *args):
     controls = self._print_sequence_pretty(self.controls, ',', printer, *args)
     gate = printer._print(self.gate)
     gate_name = stringPict(unicode(self.gate_name))
     first = self._print_subscript_pretty(gate_name, controls)
     gate = self._print_parens_pretty(gate)
     final = prettyForm(*first.right((gate)))
     return final
开发者ID:yangle,项目名称:sympy,代码行数:8,代码来源:gate.py


示例16: _pretty

    def _pretty(self, printer, *args):
        m = ((printer._print(self.j1), printer._print(self.m1)), \
            (printer._print(self.j2), printer._print(self.m2)), \
            (printer._print(self.j3), printer._print(self.m3)))
        hsep = 2
        vsep = 1
        maxw = [-1] * 3
        for j in range(3):
            maxw[j] = max([ m[j][i].width() for i in range(2) ])
        D = None
        for i in range(2):
            D_row = None
            for j in range(3):
                s = m[j][i]
                wdelta = maxw[j] - s.width()
                wleft  = wdelta //2
                wright = wdelta - wleft

                s = prettyForm(*s.right(' '*wright))
                s = prettyForm(*s.left(' '*wleft))

                if D_row is None:
                    D_row = s
                    continue
                D_row = prettyForm(*D_row.right(' '*hsep))
                D_row = prettyForm(*D_row.right(s))
            if D is None:
                D = D_row
                continue
            for _ in range(vsep):
                D = prettyForm(*D.below(' '))
            D = prettyForm(*D.below(D_row))
        D = prettyForm(*D.parens())
        return D
开发者ID:lazovich,项目名称:sympy,代码行数:34,代码来源:cg.py


示例17: _print_Function

 def _print_Function(self, e):
     from sympy.physics.vector.functions import dynamicsymbols
     t = dynamicsymbols._t
     # XXX works only for applied functions
     func = e.func
     args = e.args
     func_name = func.__name__
     prettyFunc = self._print(C.Symbol(func_name))
     prettyArgs = prettyForm(*self._print_seq(args).parens())
     # If this function is an Undefined function of t, it is probably a
     # dynamic symbol, so we'll skip the (t). The rest of the code is
     # identical to the normal PrettyPrinter code
     if isinstance(func, UndefinedFunction) and (args == (t,)):
         pform = prettyForm(binding=prettyForm.FUNC,
                    *stringPict.next(prettyFunc))
     else:
         pform = prettyForm(binding=prettyForm.FUNC,
                    *stringPict.next(prettyFunc, prettyArgs))
     # store pform parts so it can be reassembled e.g. when powered
     pform.prettyFunc = prettyFunc
     pform.prettyArgs = prettyArgs
     return pform
开发者ID:adhbh,项目名称:sympy,代码行数:22,代码来源:printers.py


示例18: render

            def render(self, *args, **kwargs):
                ar = e.args  # just to shorten things
                if len(ar) == 0:
                    return unicode(0)
                settings = printer._settings if printer else {}
                vp = printer if printer else VectorPrettyPrinter(settings)
                pforms = []  # output list, to be concatenated to a string
                for i, v in enumerate(ar):
                    for j in 0, 1, 2:
                        # if the coef of the basis vector is 1, we skip the 1
                        if ar[i][0][j] == 1:
                            pform = vp._print(ar[i][1].pretty_vecs[j])
                        # if the coef of the basis vector is -1, we skip the 1
                        elif ar[i][0][j] == -1:
                            pform = vp._print(ar[i][1].pretty_vecs[j])
                            pform= prettyForm(*pform.left(" - "))
                            bin = prettyForm.NEG
                            pform = prettyForm(binding=bin, *pform)
                        elif ar[i][0][j] != 0:
                            # If the basis vector coeff is not 1 or -1,
                            # we might wrap it in parentheses, for readability.
                            if isinstance(ar[i][0][j], Add):
                                pform = vp._print(
                                    ar[i][0][j]).parens()
                            else:
                                pform = vp._print(
                                    ar[i][0][j])
                            pform = prettyForm(*pform.right(" ",
                                                ar[i][1].pretty_vecs[j]))
                        else:
                            continue
                        pforms.append(pform)

                pform = prettyForm.__add__(*pforms)
                kwargs["wrap_line"] = kwargs.get("wrap_line")
                kwargs["num_columns"] = kwargs.get("num_columns")
                out_str = pform.render(*args, **kwargs)
                mlines = [line.rstrip() for line in out_str.split("\n")]
                return "\n".join(mlines)
开发者ID:abhi98khandelwal,项目名称:sympy,代码行数:39,代码来源:vector.py


示例19: _pretty

    def _pretty(self, printer, *args):
        bot = printer._print_seq((self.j1, self.m1, self.j2, self.m2), delimiter=',')
        top = printer._print_seq((self.j3, self.m3), delimiter=',')

        pad = max(top.width(), bot.width())
        bot = prettyForm(*bot.left(' '))
        top = prettyForm(*top.left(' '))

        if not pad == bot.width():
            bot = prettyForm(*bot.right(' ' * (pad-bot.width())))
        if not pad == top.width():
            top = prettyForm(*top.right(' ' * (pad-top.width())))
        s = stringPict('C' + ' '*pad)
        s = prettyForm(*s.below(bot))
        s = prettyForm(*s.above(top))
        return s
开发者ID:BDGLunde,项目名称:sympy,代码行数:16,代码来源:cg.py


示例20: _pretty

 def _pretty(self, printer, *args):
     pform = printer._print(self.args[0], *args)
     pform = prettyForm(*pform.right((prettyForm(u","))))
     pform = prettyForm(*pform.right((printer._print(self.args[1], *args))))
     pform = prettyForm(*pform.parens(left="{", right="}"))
     return pform
开发者ID:latot,项目名称:sympy,代码行数:6,代码来源:anticommutator.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python stringpict.stringPict函数代码示例发布时间:2022-05-27
下一篇:
Python pretty.xpretty函数代码示例发布时间: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