Пример #1
0
 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
Пример #2
0
 def _pretty(self, printer, *args):
     pform_exp = printer._print(self.exp, *args)
     if printer._use_unicode:
         pform_exp = prettyForm(*pform_exp.left(prettyForm(u'\N{N-ARY CIRCLED TIMES OPERATOR}')))
     else:
         pform_exp = prettyForm(*pform_exp.left(prettyForm('x')))
     pform_base = printer._print(self.base, *args)
     return pform_base**pform_exp
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
 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
Пример #6
0
 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
Пример #7
0
 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
Пример #8
0
    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
Пример #9
0
 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))
Пример #10
0
    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
Пример #11
0
 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
Пример #12
0
 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
Пример #13
0
 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
Пример #14
0
 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
Пример #15
0
 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'))
Пример #16
0
 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:
             if printer._use_unicode:
                 pform = prettyForm(*pform.right(u' \N{CIRCLED PLUS} '))
             else:
                 pform = prettyForm(*pform.right(' + '))
     return pform
Пример #17
0
 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
Пример #18
0
    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
Пример #19
0
            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)
Пример #20
0
 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
Пример #21
0
    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
Пример #22
0
    def _pretty(self, printer, *args):
        m = ((printer._print(self.j1), printer._print(self.j3),
              printer._print(self.j13)),
             (printer._print(self.j2), printer._print(self.j4),
              printer._print(self.j24)), (printer._print(self.j12),
                                          printer._print(self.j34),
                                          printer._print(self.j)))
        hsep = 2
        vsep = 1
        maxw = [-1] * 3
        for j in range(3):
            maxw[j] = max([m[j][i].width() for i in range(3)])
        D = None
        for i in range(3):
            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(left='{', right='}'))
        return D
Пример #23
0
 def _pretty(self, printer, *args):
     # u = u('\u2108') # script
     ustr = u('\u0048')
     return prettyForm(ustr)
Пример #24
0
 def _print_contents_pretty(self, printer, *args):
     from sympy.printing.pretty.stringpict import prettyForm
     pform = printer._print(self.args[0], *args)
     pform = pform**prettyForm(u('\N{DAGGER}'))
     return pform
Пример #25
0
 def _pretty(self, printer, *args):
     a = stringPict('J')
     b = stringPict('2')
     top = stringPict(*b.left(' ' * a.width()))
     bot = stringPict(*a.right(' ' * b.width()))
     return prettyForm(binding=prettyForm.POW, *bot.above(top))
Пример #26
0
    def _pretty(self, printer, *args):
        top = printer._print(self.j)

        bot = printer._print(self.m)
        bot = prettyForm(*bot.right(','))
        bot = prettyForm(*bot.right(printer._print(self.mp)))

        pad = max(top.width(), bot.width())
        top = prettyForm(*top.left(' '))
        bot = prettyForm(*bot.left(' '))
        if pad > top.width():
            top = prettyForm(*top.right(' ' * (pad - top.width())))
        if pad > bot.width():
            bot = prettyForm(*bot.right(' ' * (pad - bot.width())))

        if self.alpha == 0 and self.gamma == 0:
            args = printer._print(self.beta)

            s = stringPict('d' + ' ' * pad)
        else:
            args = printer._print(self.alpha)
            args = prettyForm(*args.right(','))
            args = prettyForm(*args.right(printer._print(self.beta)))
            args = prettyForm(*args.right(','))
            args = prettyForm(*args.right(printer._print(self.gamma)))

            s = stringPict('D' + ' ' * pad)

        args = prettyForm(*args.parens())
        s = prettyForm(*s.above(top))
        s = prettyForm(*s.below(bot))
        s = prettyForm(*s.right(args))
        return s
Пример #27
0
 def _print_contents_pretty(self, printer, *args):
     return prettyForm('I')
Пример #28
0
 def _pretty(self, printer, *args):
     ustr = u'\N{LATIN CAPITAL LETTER H}'
     return prettyForm(ustr)
Пример #29
0
 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
Пример #30
0
 def _pretty(self, printer, *args):
     pform = self.ket._pretty(printer, *args)
     return prettyForm(*pform.right(self.bra._pretty(printer, *args)))
Пример #31
0
 def _print_operator_name_pretty(self, printer, *args):
     return prettyForm(self.__class__.__name__)
Пример #32
0
 def _pretty(self, printer=None):
     return prettyForm(self._pretty_form)
Пример #33
0
 def _pretty(self, printer, *args):
     if self.is_zero:
         return prettyForm(pretty_symbol("0"))
     return prettyForm(
         pretty_symbol("%s_%s%s" % (self.t, printer._print(
             self.args[0]), printer._print(self.args[1]))))
Пример #34
0
 def _pretty(self, printer, *args):
     # u = u'\u2108' # script
     u = u'\u0048'
     return prettyForm(u)
Пример #35
0
 def _pretty(self, printer, *args):
     pform_exp = printer._print(self.exp, *args)
     pform_exp = prettyForm(*pform_exp.left(prettyForm(u'\u2a02')))
     pform_base = printer._print(self.base, *args)
     return pform_base**pform_exp
Пример #36
0
 def _pretty(self, printer, *args):
     if printer._use_unicode:
         return prettyForm(('\u210f'))
     return prettyForm('hbar')
Пример #37
0
 def _pretty(self, printer, *args):
     pform_exp = prettyForm(u"2")
     pform_base = prettyForm(u"L")
     return pform_base**pform_exp
Пример #38
0
 def _print_operator_name_pretty(self, printer, *args):
     return prettyForm(self.__class__.__name__)
Пример #39
0
 def _pretty(self, printer, *args):
     ustr = u'\N{LATIN CAPITAL LETTER C}'
     pform_exp = printer._print(self.dimension, *args)
     pform_base = prettyForm(ustr)
     return pform_base**pform_exp
Пример #40
0
    def _pretty(self, printer, *args):

        if (_combined_printing and
                (all([isinstance(arg, Ket) for arg in self.args]) or
                 all([isinstance(arg, Bra) for arg in self.args]))):

            length = len(self.args)
            pform = printer._print('', *args)
            for i in range(length):
                next_pform = printer._print('', *args)
                length_i = len(self.args[i].args)
                for j in range(length_i):
                    part_pform = printer._print(self.args[i].args[j], *args)
                    next_pform = prettyForm(*next_pform.right(part_pform))
                    if j != length_i - 1:
                        next_pform = prettyForm(*next_pform.right(', '))

                if len(self.args[i].args) > 1:
                    next_pform = prettyForm(
                        *next_pform.parens(left='{', right='}'))
                pform = prettyForm(*pform.right(next_pform))
                if i != length - 1:
                    pform = prettyForm(*pform.right(',' + ' '))

            pform = prettyForm(*pform.left(self.args[0].lbracket))
            pform = prettyForm(*pform.right(self.args[0].rbracket))
            return pform

        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:
                if printer._use_unicode:
                    pform = prettyForm(*pform.right('\N{N-ARY CIRCLED TIMES OPERATOR}' + ' '))
                else:
                    pform = prettyForm(*pform.right('x' + ' '))
        return pform
Пример #41
0
 def _pretty(self, printer, *args):
     # u = u'\u2102' # script
     u = u'\u0043'
     pform_exp = printer._print(self.dimension, *args)
     pform_base = prettyForm(u)
     return pform_base**pform_exp
Пример #42
0
 def _print_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
Пример #43
0
    def _pretty(self, printer, *args):
        bot = printer._print(self.j1)
        bot = prettyForm(*bot.right(','))
        bot = prettyForm(*bot.right(printer._print(self.m1)))
        bot = prettyForm(*bot.right(','))
        bot = prettyForm(*bot.right(printer._print(self.j2)))
        bot = prettyForm(*bot.right(','))
        bot = prettyForm(*bot.right(printer._print(self.m2)))
        top = printer._print(self.j3)
        top = prettyForm(*top.right(','))
        top = prettyForm(*top.right(printer._print(self.m3)))

        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
Пример #44
0
 def _pretty(self, printer, *args):
     pform_exp = prettyForm(u'2')
     pform_base = prettyForm(u'L')
     return pform_base**pform_exp
Пример #45
0
 def _print_subscript_pretty(self, a, b):
     top = prettyForm(*b.left(' ' * a.width()))
     bot = prettyForm(*a.right(' ' * b.width()))
     return prettyForm(binding=prettyForm.POW, *bot.below(top))
Пример #46
0
 def _print_operator_name_pretty(self, printer, *args):
     return prettyForm(u"\u03C1")
Пример #47
0
class KetBase(StateBase):
    """Base class for Kets.

    This class defines the dual property and the brackets for printing. This
    is an abstract base class and you should not instantiate it directly,
    instead use Ket.
    """

    lbracket = '|'
    rbracket = '>'
    lbracket_pretty = prettyForm(_straight_bracket)
    rbracket_pretty = prettyForm(_rbracket)
    lbracket_latex = r'\left|'
    rbracket_latex = r'\right\rangle '

    @classmethod
    def default_args(self):
        return ("psi",)

    @classmethod
    def dual_class(self):
        return BraBase

    def __mul__(self, other):
        """KetBase*other"""
        from sympy.physics.quantum.operator import OuterProduct
        if isinstance(other, BraBase):
            return OuterProduct(self, other)
        else:
            return Expr.__mul__(self, other)

    def __rmul__(self, other):
        """other*KetBase"""
        from sympy.physics.quantum.innerproduct import InnerProduct
        if isinstance(other, BraBase):
            return InnerProduct(other, self)
        else:
            return Expr.__rmul__(self, other)

    #-------------------------------------------------------------------------
    # _eval_* methods
    #-------------------------------------------------------------------------

    def _eval_innerproduct(self, bra, **hints):
        """Evaluate the inner product betweeen this ket and a bra.

        This is called to compute <bra|ket>, where the ket is ``self``.

        This method will dispatch to sub-methods having the format::

            def _eval_innerproduct_BraClass(self, **hints):

        Subclasses should define these methods (one for each BraClass) to
        teach the ket how to take inner products with bras.
        """
        return dispatch_method(self, '_eval_innerproduct', bra, **hints)

    def _apply_operator(self, op, **options):
        """Apply an Operator to this Ket.

        This method will dispatch to methods having the format::

            def _apply_operator_OperatorName(op, **options):

        Subclasses should define these methods (one for each OperatorName) to
        teach the Ket how operators act on it.

        Parameters
        ==========

        op : Operator
            The Operator that is acting on the Ket.
        options : dict
            A dict of key/value pairs that control how the operator is applied
            to the Ket.
        """
        return dispatch_method(self, '_apply_operator', op, **options)
Пример #48
0
 def _print_operator_name_pretty(self, printer, *args):
     return prettyForm(u"\u211B" + u" ")
Пример #49
0
 def _print_contents_pretty(self, printer, *args):
     from sympy.printing.pretty.stringpict import prettyForm
     pform = self._print_label_pretty(printer, *args)
     pform = prettyForm(*pform.left((self.lbracket_pretty)))
     pform = prettyForm(*pform.right((self.rbracket_pretty)))
     return pform
Пример #50
0
 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
Пример #51
0
 def _pretty(self, printer, *args):
     pform = self.ket._pretty(printer, *args)
     return prettyForm(*pform.right(self.bra._pretty(printer, *args)))
Пример #52
0
 def _pretty(self, printer, *args):
     if printer._use_unicode:
         return prettyForm(u'\N{PLANCK CONSTANT OVER TWO PI}')
     return prettyForm('hbar')
Пример #53
0
    def _pretty(self, printer, *args):
        top = printer._print(self.j)

        bot = printer._print(self.m)
        bot = prettyForm(*bot.right(","))
        bot = prettyForm(*bot.right(printer._print(self.mp)))

        pad = max(top.width(), bot.width())
        top = prettyForm(*top.left(" "))
        bot = prettyForm(*bot.left(" "))
        if pad > top.width():
            top = prettyForm(*top.right(" " * (pad - top.width())))
        if pad > bot.width():
            bot = prettyForm(*bot.right(" " * (pad - bot.width())))

        if self.alpha == 0 and self.gamma == 0:
            args = printer._print(self.beta)

            s = stringPict("d" + " " * pad)
        else:
            args = printer._print(self.alpha)
            args = prettyForm(*args.right(","))
            args = prettyForm(*args.right(printer._print(self.beta)))
            args = prettyForm(*args.right(","))
            args = prettyForm(*args.right(printer._print(self.gamma)))

            s = stringPict("D" + " " * pad)

        args = prettyForm(*args.parens())
        s = prettyForm(*s.above(top))
        s = prettyForm(*s.below(bot))
        s = prettyForm(*s.right(args))
        return s
Пример #54
0
 def _print_label_pretty(self, printer, *args):
     label = self._print_label(printer, *args)
     return prettyForm(label)
Пример #55
0
 def _pretty(self, printer, *args):
     ustr = u'\N{LATIN CAPITAL LETTER C}'
     pform_exp = printer._print(self.dimension, *args)
     pform_base = prettyForm(ustr)
     return pform_base**pform_exp
Пример #56
0
 def _print_sequence_pretty(self, seq, sep, printer, *args):
     pform = printer._print(seq[0], *args)
     for item in seq[1:]:
         pform = prettyForm(*pform.right((sep)))
         pform = prettyForm(*pform.right((printer._print(item, *args))))
     return pform
Пример #57
0
 def _pretty(self, printer, *args):
     pform_exp = prettyForm(u'2')
     pform_base = prettyForm(u'L')
     return pform_base**pform_exp
Пример #58
0
 def _print_parens_pretty(self, pform, left='(', right=')'):
     return prettyForm(*pform.parens(left=left, right=right))
Пример #59
0
 def _pretty(self, printer, *args):
     ustr = u'\N{LATIN CAPITAL LETTER F}'
     return prettyForm(ustr)