Bases: sage.repl.display.fancy_repr.ObjectReprABC
Ascii Art representation
Return ascii art format.
INPUT:
OUTPUT:
Boolean. Whether the representer is applicable to obj. If True, the string representation is appended to p.
EXAMPLES:
sage: from sage.repl.display.fancy_repr import AsciiArtRepr
sage: pp = AsciiArtRepr()
sage: pp.format_string(x/2)
'x\n-\n2'
Bases: sage.repl.display.fancy_repr.ObjectReprABC
Representation including help for large Sage matrices
Format matrix.
INPUT:
OUTPUT:
Boolean. Whether the representer is applicable to obj. If True, the string representation is appended to p.
EXAMPLES:
sage: from sage.repl.display.fancy_repr import LargeMatrixHelpRepr
sage: M = identity_matrix(40)
sage: pp = LargeMatrixHelpRepr()
sage: pp.format_string(M)
"40 x 40 dense matrix over Integer Ring (use the '.str()' method to see the entries)"
sage: pp.format_string([M, M])
'--- object not handled by representer ---'
Leads to:
sage: M
40 x 40 dense matrix over Integer Ring (use the '.str()' method to see the entries)
sage: [M, M]
[40 x 40 dense matrix over Integer Ring,
40 x 40 dense matrix over Integer Ring]
Bases: object
The abstract base class of an object representer.
Format object.
INPUT:
OUTPUT:
Boolean. Whether the representer is applicable to obj. If True, the string representation is appended to p.
EXAMPLES:
sage: from sage.repl.display.fancy_repr import ObjectReprABC
sage: ObjectReprABC().format_string(123) # indirect doctest
'Error: ObjectReprABC.__call__ is abstract'
For doctesting only: Directly return string.
INPUT:
OUTPUT:
String.
EXAMPLES:
sage: from sage.repl.display.fancy_repr import ObjectReprABC
sage: ObjectReprABC().format_string(123)
'Error: ObjectReprABC.__call__ is abstract'
Bases: sage.repl.display.fancy_repr.ObjectReprABC
The ordinary Python representation
Format matrix.
INPUT:
OUTPUT:
Boolean. Whether the representer is applicable to obj. If True, the string representation is appended to p.
EXAMPLES:
sage: from sage.repl.display.fancy_repr import PlainPythonRepr
sage: pp = PlainPythonRepr()
sage: pp.format_string(type(1))
"<type 'sage.rings.integer.Integer'>"
Do not swallow a trailing newline at the end of the output of a custom representer. Note that it is undesirable to have a trailing newline, and if we don’t display it you can’t fix it:
sage: class Newline(object):
....: def __repr__(self):
....: return 'newline\n'
sage: n = Newline()
sage: pp.format_string(n)
'newline\n'
sage: pp.format_string([n, n, n])
'[newline\n, newline\n, newline\n]'
sage: [n, n, n]
[newline
, newline
, newline
]
Bases: sage.repl.display.fancy_repr.ObjectReprABC
Some selected representers from IPython
EXAMPLES:
sage: from sage.repl.display.fancy_repr import SomeIPythonRepr
sage: SomeIPythonRepr()
SomeIPythonRepr pretty printer
Format object.
INPUT:
OUTPUT:
Boolean. Whether the representer is applicable to obj. If True, the string representation is appended to p.
EXAMPLES:
sage: from sage.repl.display.fancy_repr import SomeIPythonRepr
sage: pp = SomeIPythonRepr()
sage: pp.format_string(set([1, 2, 3]))
'{1, 2, 3}'
Bases: sage.repl.display.fancy_repr.ObjectReprABC
Special representation for lists with tall entries (e.g. matrices)
Format list/tuple.
INPUT:
OUTPUT:
Boolean. Whether the representer is applicable to obj. If True, the string representation is appended to p.
EXAMPLES:
sage: from sage.repl.display.fancy_repr import TallListRepr
sage: format_list = TallListRepr().format_string
sage: format_list([1, 2, identity_matrix(2)])
'[\n [1 0]\n1, 2, [0 1]\n]'
Bases: sage.repl.display.fancy_repr.ObjectReprABC
Typeset representation
Return typeset format.
INPUT:
OUTPUT:
Boolean. Whether the representer is applicable to obj. If True, the string representation is appended to p.
EXAMPLES:
sage: from sage.repl.display.fancy_repr import TypesetRepr
sage: pp = TypesetRepr()
sage: pp.format_string(x/2)
<html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{2} \, x</script></html>
''