Symbols for Character Art - Utilities

Skip to content
Back to top
View this page
Edit this page

# Symbols for Character Art

This module defines single- and multi-line symbols.

EXAMPLES:

Sage

    sage: from sage.typeset.symbols import *

    sage: symbols = ascii_art('')
    sage: for i in range(1, 5):
    ....:     symbols += ascii_left_parenthesis.character_art(i)
    ....:     symbols += ascii_art(' ')
    ....:     symbols += ascii_right_parenthesis.character_art(i)
    ....:     symbols += ascii_art(' ')
    sage: for i in range(1, 5):
    ....:     symbols += ascii_left_square_bracket.character_art(i)
    ....:     symbols += ascii_art(' ')
    ....:     symbols += ascii_right_square_bracket.character_art(i)
    ....:     symbols += ascii_art(' ')
    sage: for i in range(1, 5):
    ....:     symbols += ascii_left_curly_brace.character_art(i)
    ....:     symbols += ascii_art(' ')
    ....:     symbols += ascii_right_curly_brace.character_art(i)
    ....:     symbols += ascii_art(' ')
    sage: symbols
                ( )             [ ]             { }
            ( ) ( )         [ ] [ ]         { } { }
        ( ) ( ) ( )     [ ] [ ] [ ]     { } { } { }
    ( ) ( ) ( ) ( ) [ ] [ ] [ ] [ ] { } { } { } { }

    sage: symbols = unicode_art('')
    sage: for i in range(1, 5):
    ....:     symbols += unicode_left_parenthesis.character_art(i)
    ....:     symbols += unicode_art(' ')
    ....:     symbols += unicode_right_parenthesis.character_art(i)
    ....:     symbols += unicode_art(' ')
    sage: for i in range(1, 5):
    ....:     symbols += unicode_left_square_bracket.character_art(i)
    ....:     symbols += unicode_art(' ')
    ....:     symbols += unicode_right_square_bracket.character_art(i)
    ....:     symbols += unicode_art(' ')
    sage: for i in range(1, 5):
    ....:     symbols += unicode_left_curly_brace.character_art(i)
    ....:     symbols += unicode_art(' ')
    ....:     symbols += unicode_right_curly_brace.character_art(i)
    ....:     symbols += unicode_art(' ')
    sage: symbols
                ⎛ ⎞             ⎡ ⎤             ⎧ ⎫
            ⎛ ⎞ ⎜ ⎟         ⎡ ⎤ ⎢ ⎥         ⎧ ⎫ ⎭ ⎩
        ⎛ ⎞ ⎜ ⎟ ⎜ ⎟     ⎡ ⎤ ⎢ ⎥ ⎢ ⎥     ⎰ ⎱ ⎨ ⎬ ⎫ ⎧
    ( ) ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ [ ] ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ { } ⎱ ⎰ ⎩ ⎭ ⎩ ⎭

Python

    >>> from sage.all import *
    >>> from sage.typeset.symbols import *

    >>> symbols = ascii_art('')
    >>> for i in range(Integer(1), Integer(5)):
    ...     symbols += ascii_left_parenthesis.character_art(i)
    ...     symbols += ascii_art(' ')
    ...     symbols += ascii_right_parenthesis.character_art(i)
    ...     symbols += ascii_art(' ')
    >>> for i in range(Integer(1), Integer(5)):
    ...     symbols += ascii_left_square_bracket.character_art(i)
    ...     symbols += ascii_art(' ')
    ...     symbols += ascii_right_square_bracket.character_art(i)
    ...     symbols += ascii_art(' ')
    >>> for i in range(Integer(1), Integer(5)):
    ...     symbols += ascii_left_curly_brace.character_art(i)
    ...     symbols += ascii_art(' ')
    ...     symbols += ascii_right_curly_brace.character_art(i)
    ...     symbols += ascii_art(' ')
    >>> symbols
                ( )             [ ]             { }
            ( ) ( )         [ ] [ ]         { } { }
        ( ) ( ) ( )     [ ] [ ] [ ]     { } { } { }
    ( ) ( ) ( ) ( ) [ ] [ ] [ ] [ ] { } { } { } { }

    >>> symbols = unicode_art('')
    >>> for i in range(Integer(1), Integer(5)):
    ...     symbols += unicode_left_parenthesis.character_art(i)
    ...     symbols += unicode_art(' ')
    ...     symbols += unicode_right_parenthesis.character_art(i)
    ...     symbols += unicode_art(' ')
    >>> for i in range(Integer(1), Integer(5)):
    ...     symbols += unicode_left_square_bracket.character_art(i)
    ...     symbols += unicode_art(' ')
    ...     symbols += unicode_right_square_bracket.character_art(i)
    ...     symbols += unicode_art(' ')
    >>> for i in range(Integer(1), Integer(5)):
    ...     symbols += unicode_left_curly_brace.character_art(i)
    ...     symbols += unicode_art(' ')
    ...     symbols += unicode_right_curly_brace.character_art(i)
    ...     symbols += unicode_art(' ')
    >>> symbols
                ⎛ ⎞             ⎡ ⎤             ⎧ ⎫
            ⎛ ⎞ ⎜ ⎟         ⎡ ⎤ ⎢ ⎥         ⎧ ⎫ ⎭ ⎩
        ⎛ ⎞ ⎜ ⎟ ⎜ ⎟     ⎡ ⎤ ⎢ ⎥ ⎢ ⎥     ⎰ ⎱ ⎨ ⎬ ⎫ ⎧
    ( ) ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ [ ] ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ { } ⎱ ⎰ ⎩ ⎭ ⎩ ⎭

class sage.typeset.symbols.CompoundAsciiSymbol(character, top, extension, bottom, middle=None, middle_top=None, middle_bottom=None, top_2=None, bottom_2=None)

  Bases: `CompoundSymbol`

  character_art(num_lines)

    Return the ASCII art of the symbol.

    EXAMPLES:

    Sage

        sage: from sage.typeset.symbols import *
        sage: ascii_left_curly_brace.character_art(3)
        {
        {
        {

    Python

        >>> from sage.all import *
        >>> from sage.typeset.symbols import *
        >>> ascii_left_curly_brace.character_art(Integer(3))
        {
        {
        {

class sage.typeset.symbols.CompoundSymbol(character, top, extension, bottom, middle=None, middle_top=None, middle_bottom=None, top_2=None, bottom_2=None)

  Bases: `SageObject`

  A multi-character (ascii/unicode art) symbol.

  INPUT:

  Instead of a string, each of these can be unicode in Python 2:

  - `character` – string; the single-line version of the symbol

  - `top` – string; the top line of a multi-line symbol

  - `extension` – string; the extension line of a multi-line symbol (will be repeated)

  - `bottom` – string; the bottom line of a multi-line symbol

  - `middle` – (optional) string; the middle part, for example in curly braces. Will be used only once for the symbol, and only if its height is odd.

  - `middle_top` – (optional) string; the upper half of the 2-line middle part if the height of the symbol is even. Will be used only once for the symbol.

  - `middle_bottom` – (optional) string; the lower half of the 2-line middle part if the height of the symbol is even. Will be used only once for the symbol.

  - `top_2` – (optional) string; the upper half of a 2-line symbol

  - `bottom_2` – (optional) string; the lower half of a 2-line symbol

  EXAMPLES:

  Sage

      sage: from sage.typeset.symbols import CompoundSymbol
      sage: i = CompoundSymbol('I', '+', '|', '+', '|')
      sage: i.print_to_stdout(1)
      I
      sage: i.print_to_stdout(3)
      +
      |
      +

  Python

      >>> from sage.all import *
      >>> from sage.typeset.symbols import CompoundSymbol
      >>> i = CompoundSymbol('I', '+', '|', '+', '|')
      >>> i.print_to_stdout(Integer(1))
      I
      >>> i.print_to_stdout(Integer(3))
      +
      |
      +

  print_to_stdout(num_lines)

    Print the multi-line symbol.

    This method is for testing purposes.

    INPUT:

    - `num_lines` – integer; the total number of lines

    EXAMPLES:

    Sage

        sage: from sage.typeset.symbols import *
        sage: unicode_integral.print_to_stdout(1)
        ∫
        sage: unicode_integral.print_to_stdout(2)
        ⌠
        ⌡
        sage: unicode_integral.print_to_stdout(3)
        ⌠
        ⎮
        ⌡
        sage: unicode_integral.print_to_stdout(4)
        ⌠
        ⎮
        ⎮
        ⌡

    Python

        >>> from sage.all import *
        >>> from sage.typeset.symbols import *
        >>> unicode_integral.print_to_stdout(Integer(1))
        ∫
        >>> unicode_integral.print_to_stdout(Integer(2))
        ⌠
        ⌡
        >>> unicode_integral.print_to_stdout(Integer(3))
        ⌠
        ⎮
        ⌡
        >>> unicode_integral.print_to_stdout(Integer(4))
        ⌠
        ⎮
        ⎮
        ⌡

class sage.typeset.symbols.CompoundUnicodeSymbol(character, top, extension, bottom, middle=None, middle_top=None, middle_bottom=None, top_2=None, bottom_2=None)

  Bases: `CompoundSymbol`

  character_art(num_lines)

    Return the unicode art of the symbol.

    EXAMPLES:

    Sage

        sage: from sage.typeset.symbols import *
        sage: unicode_left_curly_brace.character_art(3)
        ⎧
        ⎨
        ⎩

    Python

        >>> from sage.all import *
        >>> from sage.typeset.symbols import *
        >>> unicode_left_curly_brace.character_art(Integer(3))
        ⎧
        ⎨
        ⎩