コード例 #1
0
    def _unicode_art_(self):
        r"""
        Return a unicode art representation of ``self``

        TESTS::

            sage: t = path_tableaux.DyckPath([0,1,2,3,2,1,0])
            sage: unicode_art(path_tableaux.CylindricalDiagram(t))
             0 1 2 3 2 1 0
               0 1 2 1 0 1 0
                 0 1 0 1 2 1 0
                   0 1 2 3 2 1 0
                     0 1 2 1 0 1 0
                       0 1 0 1 2 1 0
                         0 1 2 3 2 1 0

            sage: t = path_tableaux.FriezePattern([1,3,4,5,1])
            sage: unicode_art(path_tableaux.CylindricalDiagram(t))
               0   1   3   4   5   1   0
                   0   1 5/3 7/3 2/3   1   0
                       0   1   2   1   3   1   0
                           0   1   1   4 5/3   1   0
                               0   1   5 7/3   2   1   0
                                   0   1 2/3   1   1   1   0
                                       0   1   3   4   5   1   0
        """
        from sage.typeset.unicode_art import unicode_art
        from sage.misc.misc_c import prod
        data = [[unicode_art(x) for x in row] for row in self.diagram]
        if not data[0]:
            data[0] = [unicode_art('')]  # Put sometime there
        max_width = max(max(len(x) for x in row) for row in data if row)
        return prod((sum((unicode_art(' '*(max_width-len(x)+1)) + x for x in row), unicode_art(''))
                    for row in data), unicode_art(''))
コード例 #2
0
 def _unicode_art_(self):
     """
     Unicode art representation of the array.
     """
     l = len(repr(self.n - 1))
     fmt = '%{}d: '.format(l)
     art = [unicode_art(M) for M in self.A]
     return unicode_art("\n".join((fmt % i) + "\n"*a.height()
                                  for i, a in enumerate(art))) + \
         unicode_art("\n".join(sum([a._matrix + [""] for a in art], [])))
コード例 #3
0
 def _unicode_art_(self):
     """
     Unicode art representation of the array.
     """
     l = len(repr(self.n - 1))
     fmt = '%{}d'.format(l)
     art = [("(%s, %s): " % (fmt % i, fmt % j), unicode_art(M))
            for i, A in enumerate(self.A) for j, M in enumerate(A)]
     return unicode_art("\n".join(i + "\n"*a.height() for i, a in art)) + \
         unicode_art("\n".join(sum([a._matrix + [""] for i, a in art],
                                   [])))
コード例 #4
0
ファイル: backend_base.py プロジェクト: sampadsaha5/sage
    def unicode_art_formatter(self, obj, **kwds):
        r"""
        Hook to override how unicode art is being formatted.

        INPUT:

        - ``obj`` -- anything.

        - ``**kwds`` -- optional keyword arguments to control the
          formatting. Supported are:

            * ``concatenate`` -- boolean (default: ``False``). If
              ``True``, the argument ``obj`` must be iterable and its
              entries will be concatenated. There is a single
              whitespace between entries.

        OUTPUT:

        Instance of
        :class:`~sage.repl.rich_output.output_basic.OutputUnicodeArt`
        containing the unicode art string representation of the object.

        EXAMPLES::

            sage: from sage.repl.rich_output.backend_base import BackendBase
            sage: backend = BackendBase()
            sage: out = backend.unicode_art_formatter(range(30))
            sage: out
            OutputUnicodeArt container
            sage: out.unicode_art
            buffer containing 114 bytes
            sage: print(out.unicode_art.get())
            [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
            <BLANKLINE>
            22, 23, 24, 25, 26, 27, 28, 29 ]

            sage: backend.unicode_art_formatter([1,2,3], concatenate=False).unicode_art.get()
            '[ 1, 2, 3 ]'
            sage: backend.unicode_art_formatter([1,2,3], concatenate=True ).unicode_art.get()
            '1 2 3'
        """
        from sage.typeset.unicode_art import unicode_art, empty_unicode_art

        if kwds.get("concatenate", False):
            result = unicode_art(*obj, sep=" ")
        else:
            result = unicode_art(obj)
        from sage.repl.rich_output.output_basic import OutputUnicodeArt

        return OutputUnicodeArt(str(result))
コード例 #5
0
    def unicode_art_formatter(self, obj, **kwds):
        r"""
        Hook to override how unicode art is being formatted.

        INPUT:

        - ``obj`` -- anything.

        - ``**kwds`` -- optional keyword arguments to control the
          formatting. Supported are:

            * ``concatenate`` -- boolean (default: ``False``). If
              ``True``, the argument ``obj`` must be iterable and its
              entries will be concatenated. There is a single
              whitespace between entries.

        OUTPUT:

        Instance of
        :class:`~sage.repl.rich_output.output_basic.OutputUnicodeArt`
        containing the unicode art string representation of the object.

        EXAMPLES::

            sage: from sage.repl.rich_output.backend_base import BackendBase
            sage: backend = BackendBase()
            sage: out = backend.unicode_art_formatter(range(30))
            sage: out
            OutputUnicodeArt container
            sage: out.unicode_art
            buffer containing 114 bytes
            sage: print(out.unicode_art.get())
            [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
            <BLANKLINE>
            22, 23, 24, 25, 26, 27, 28, 29 ]

            sage: backend.unicode_art_formatter([1,2,3], concatenate=False).unicode_art.get()
            '[ 1, 2, 3 ]'
            sage: backend.unicode_art_formatter([1,2,3], concatenate=True ).unicode_art.get()
            '1 2 3'
        """
        from sage.typeset.unicode_art import unicode_art, empty_unicode_art
        if kwds.get('concatenate', False):
            result = unicode_art(*obj, sep=' ')
        else:
            result = unicode_art(obj)
        from sage.repl.rich_output.output_basic import OutputUnicodeArt
        return OutputUnicodeArt(str(result))
コード例 #6
0
ファイル: indexed_generators.py プロジェクト: yunboliu27/sage
    def _unicode_art_generator(self, m):
        r"""
        Return an unicode art representing the generator indexed by ``m``.

        TESTS::

            sage: R = NonCommutativeSymmetricFunctions(QQ).R()
            sage: unicode_art(R[1,2,2,4])
            R
               ┌┬┬┬┐
              ┌┼┼┴┴┘
             ┌┼┼┘
             ├┼┘
             └┘
            sage: Partitions.options.convention="french"
            sage: unicode_art(R[1,2,2,4])
            R
             ┌┐
             ├┼┐
             └┼┼┐
              └┼┼┬┬┐
               └┴┴┴┘
            sage: Partitions.options._reset()
        """
        from sage.typeset.unicode_art import UnicodeArt, unicode_art
        pref = UnicodeArt([self.prefix()])
        r = pref * (UnicodeArt([" "**Integer(len(pref))]) + unicode_art(m))
        r._baseline = r._h - 1
        return r
コード例 #7
0
ファイル: indexed_generators.py プロジェクト: mcognetta/sage
    def _unicode_art_generator(self, m):
        r"""
        Return an unicode art representing the generator indexed by ``m``.

        TESTS::

            sage: R = NonCommutativeSymmetricFunctions(QQ).R()
            sage: unicode_art(R[1,2,2,4])
            R
               ┌┬┬┬┐
              ┌┼┼┴┴┘
             ┌┼┼┘
             ├┼┘
             └┘
            sage: Partitions.options.convention="french"
            sage: unicode_art(R[1,2,2,4])
            R
             ┌┐
             ├┼┐
             └┼┼┐
              └┼┼┬┬┐
               └┴┴┴┘
            sage: Partitions.options._reset()
        """
        from sage.typeset.unicode_art import UnicodeArt, unicode_art
        pref = UnicodeArt([self.prefix()])
        r = pref * (UnicodeArt([" " ** Integer(len(pref))]) + unicode_art(m))
        r._baseline = r._h - 1
        return r
コード例 #8
0
    def _unicode_art_term(self, m):
        r"""
        Return a unicode art representation of the term indexed by ``m``.

        EXAMPLES::

            sage: d = lie_algebras.VirasoroAlgebra(QQ)
            sage: d._unicode_art_term('c')
            c
            sage: d._unicode_art_term(2)
            d₂
            sage: d._unicode_art_term(-13)
            d₋₁₃
        """
        from sage.typeset.unicode_art import unicode_art, unicode_subscript
        if isinstance(m, str):
            return unicode_art(m)
        return unicode_art('d' + unicode_subscript(m))
コード例 #9
0
    def _unicode_art_term(self, m):
        r"""
        Return a unicode art representation of the term indexed by ``m``.

        EXAMPLES::

            sage: H = lie_algebras.Heisenberg(QQ, 10)
            sage: H._unicode_art_term('p1')
            p₁
            sage: H._unicode_art_term('z')
            z
            sage: unicode_art(H.p(10))
            p₁₀
        """
        from sage.typeset.unicode_art import unicode_art, unicode_subscript
        if len(m) == 1:
            return unicode_art(m)
        return unicode_art(
            str(m[0]) +
            unicode_subscript(m[1:]))  # else it is of length at least 2
コード例 #10
0
ファイル: raag.py プロジェクト: swewers/mein_sage
    def _unicode_art_term(self, m):
        """
        Return unicode art for the basis element indexed by ``m``.

        EXAMPLES::

            sage: C4 = graphs.CycleGraph(4)
            sage: A = groups.misc.RightAngledArtin(C4)
            sage: H = A.cohomology()
            sage: H._unicode_art_term((0,1,3))
            e0∧e1∧e3
            sage: w,x,y,z = H.algebra_generators()
            sage: unicode_art(y*w + x*z)
            -e0∧e2 + e1∧e3
        """
        if not m:
            return unicode_art('1')
        import unicodedata
        wedge = unicodedata.lookup('LOGICAL AND')
        return unicode_art(*['e' + str(i) for i in m], sep=wedge)
コード例 #11
0
    def _unicode_art_term(self, m):
        r"""
        Return a unicode art representation of the term indexed by ``m``.

        EXAMPLES::

            sage: L = lie_algebras.RankTwoHeisenbergVirasoro(QQ)
            sage: L = lie_algebras.RankTwoHeisenbergVirasoro(QQ)
            sage: L._unicode_art_term(('K', 2))
            K₂
            sage: L._unicode_art_term(('t', (2,-4)))
            t⁽²˴⁻⁴⁾
            sage: L._unicode_art_term(('E', (2,-4)))
            E(2,-4)
        """
        from sage.typeset.unicode_art import unicode_art, unicode_subscript, unicode_superscript
        if m[0] == 'K':
            return unicode_art('K' + unicode_subscript(m[1]))
        if m[0] == 't':
            return unicode_art('t⁽{}˴{}⁾'.format(unicode_superscript(m[1][0]),
                                                 unicode_superscript(m[1][1])))
        return unicode_art('E({},{})'.format(m[1][0], m[1][1]))
コード例 #12
0
    def _unicode_art_term(self, m):
        r"""
        Return a unicode art representation of the term indexed by ``m``.

        EXAMPLES::

            sage: L = lie_algebras.SymplecticDerivation(QQ, 5)
            sage: L._unicode_art_term([7, 5, 2, 1])
            a₁·a₂·a₅·b₂
        """
        from sage.typeset.unicode_art import unicode_art, unicode_subscript
        g = self._g
        def label(i):
            return "a{}".format(unicode_subscript(i)) if i <= g else "b{}".format(unicode_subscript(i-g))
        return unicode_art("·".join(label(i) for i in reversed(m)))
コード例 #13
0
    def _unicode_art_(self):
        r"""
        Return a unicode art representation of ``self``.

        EXAMPLES::

            sage: G2 = AffineGroup(2, QQ)
            sage: g2 = G2([[1, 1], [0, 1]], [3,4])
            sage: unicode_art(g2)
            x ↦ ⎛1 1⎞ x + ⎛3⎞
                ⎝0 1⎠     ⎝4⎠

            sage: G3 = AffineGroup(3, QQ)
            sage: g3 = G3([[1,1,-1], [0,1,2], [0,10,2]], [3,4,5/2])
            sage: unicode_art(g3)
                ⎛ 1  1 -1⎞     ⎛  3⎞
            x ↦ ⎜ 0  1  2⎟ x + ⎜  4⎟
                ⎝ 0 10  2⎠     ⎝5/2⎠
        """
        from sage.typeset.unicode_art import unicode_art
        deg = self.parent().degree()
        A = unicode_art(self._A, baseline=deg // 2)
        b = unicode_art(self._b.column(), baseline=deg // 2)
        return unicode_art("x ↦ ") + A + unicode_art(" x + ") + b
コード例 #14
0
    def _unicode_art_term(self, x):
        r"""
        Return a unicode art representation for ``x``.

        EXAMPLES::

            sage: L = LieAlgebra(QQ, 'x,y')
            sage: H = L.Hall()
            sage: x,y = H.gens()
            sage: H._unicode_art_term(x.leading_support())
            x
            sage: a = H([x, y]).leading_support()
            sage: H._unicode_art_term(a)
            [x, y]
        """
        from sage.typeset.unicode_art import unicode_art
        return unicode_art(x)