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

Python compatibility.unicode函数代码示例

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

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



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

示例1: _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:B-Rich,项目名称:sympy,代码行数:8,代码来源:gate.py


示例2: render

            def render(self, *args, **kwargs):
                ar = e.args  # just to shorten things
                settings = printer._settings if printer else {}
                if printer:
                    use_unicode = printer._use_unicode
                else:
                    from sympy.printing.pretty.pretty_symbology import (
                        pretty_use_unicode)
                    use_unicode = pretty_use_unicode()
                mpp = printer if printer else VectorPrettyPrinter(settings)
                if len(ar) == 0:
                    return unicode(0)
                bar = u"\N{CIRCLED TIMES}" if use_unicode else "|"
                ol = []  # output list, to be concatenated to a string
                for i, v in enumerate(ar):
                    # if the coef of the dyadic is 1, we skip the 1
                    if ar[i][0] == 1:
                        ol.extend([u" + ",
                                  mpp.doprint(ar[i][1]),
                                  bar,
                                  mpp.doprint(ar[i][2])])

                    # if the coef of the dyadic is -1, we skip the 1
                    elif ar[i][0] == -1:
                        ol.extend([u" - ",
                                  mpp.doprint(ar[i][1]),
                                  bar,
                                  mpp.doprint(ar[i][2])])

                    # If the coefficient of the dyadic is not 1 or -1,
                    # we might wrap it in parentheses, for readability.
                    elif ar[i][0] != 0:
                        if isinstance(ar[i][0], Add):
                            arg_str = mpp._print(
                                ar[i][0]).parens()[0]
                        else:
                            arg_str = mpp.doprint(ar[i][0])
                        if arg_str.startswith(u"-"):
                            arg_str = arg_str[1:]
                            str_start = u" - "
                        else:
                            str_start = u" + "
                        ol.extend([str_start, arg_str, u" ",
                                  mpp.doprint(ar[i][1]),
                                  bar,
                                  mpp.doprint(ar[i][2])])

                outstr = u"".join(ol)
                if outstr.startswith(u" + "):
                    outstr = outstr[3:]
                elif outstr.startswith(" "):
                    outstr = outstr[1:]
                return outstr
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:53,代码来源:dyadic.py


示例3: 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


示例4: render

            def render(self, *args, **kwargs):
                self = e
                ar = self.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)
                ol = []  # 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:
                            ol.append(u(" + ") + 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:
                            ol.append(u(" - ") + ar[i][1].pretty_vecs[j])
                        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):
                                arg_str = vp._print(
                                    ar[i][0][j]).parens()[0]
                            else:
                                arg_str = (vp.doprint(
                                    ar[i][0][j]))

                            if arg_str[0] == u("-"):
                                arg_str = arg_str[1:]
                                str_start = u(" - ")
                            else:
                                str_start = u(" + ")
                            ol.append(str_start + arg_str + ' ' +
                                      ar[i][1].pretty_vecs[j])
                outstr = u("").join(ol)
                if outstr.startswith(u(" + ")):
                    outstr = outstr[3:]
                elif outstr.startswith(" "):
                    outstr = outstr[1:]
                return outstr
开发者ID:brajeshvit,项目名称:virtual,代码行数:39,代码来源:vector.py


示例5: _pretty

 def _pretty(self, printer, *args):
     targets = self._print_sequence_pretty(
         self.targets, ',', printer, *args)
     gate_name = stringPict(unicode(self.gate_name))
     return self._print_subscript_pretty(gate_name, targets)
开发者ID:AStorus,项目名称:sympy,代码行数:5,代码来源:gate.py


示例6: xstr

def xstr(*args):
    """call str or unicode depending on current mode"""
    if _use_unicode:
        return unicode(*args)
    else:
        return str(*args)
开发者ID:AdrianPotter,项目名称:sympy,代码行数:6,代码来源:pretty_symbology.py


示例7: preview


#.........这里部分代码省略.........
                                 "compatible object if viewer=\"BytesIO\"")
        elif viewer not in special and not find_executable(viewer):
            raise SystemError("Unrecognized viewer: %s" % viewer)


    if preamble is None:
        actual_packages = packages + ("amsmath", "amsfonts")
        if euler:
            actual_packages += ("euler",)
        package_includes = "\n" + "\n".join(["\\usepackage{%s}" % p
                                             for p in actual_packages])

        preamble = r"""\documentclass[12pt]{article}
\pagestyle{empty}
%s

\begin{document}
""" % (package_includes)
    else:
        if len(packages) > 0:
            raise ValueError("The \"packages\" keyword must not be set if a "
                             "custom LaTeX preamble was specified")
    latex_main = preamble + '\n%s\n\n' + r"\end{document}"

    if isinstance(expr, str):
        latex_string = expr
    else:
        latex_string = latex(expr, mode='inline', **latex_settings)

    try:
        workdir = tempfile.mkdtemp()

        with io.open(join(workdir, 'texput.tex'), 'w', encoding='utf-8') as fh:
            fh.write(unicode(latex_main) % u_decode(latex_string))

        if outputTexFile is not None:
            shutil.copyfile(join(workdir, 'texput.tex'), outputTexFile)

        if not find_executable('latex'):
            raise RuntimeError("latex program is not installed")

        try:
            check_output(['latex', '-halt-on-error', '-interaction=nonstopmode',
                          'texput.tex'], cwd=workdir, stderr=STDOUT)
        except CalledProcessError as e:
            raise RuntimeError(
                "'latex' exited abnormally with the following output:\n%s" %
                e.output)

        if output != "dvi":
            defaultoptions = {
                "ps": [],
                "pdf": [],
                "png": ["-T", "tight", "-z", "9", "--truecolor"],
                "svg": ["--no-fonts"],
            }

            commandend = {
                "ps": ["-o", "texput.ps", "texput.dvi"],
                "pdf": ["texput.dvi", "texput.pdf"],
                "png": ["-o", "texput.png", "texput.dvi"],
                "svg": ["-o", "texput.svg", "texput.dvi"],
            }

            if output == "svg":
                cmd = ["dvisvgm"]
开发者ID:AStorus,项目名称:sympy,代码行数:67,代码来源:preview.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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