This backend is active during doctests. It should mimic the behavior of the IPython command line as close as possible. Without actually launching image viewers, of course.
EXAMPLES:
sage: from sage.repl.rich_output import get_display_manager
sage: get_display_manager()
The Sage display manager using the doctest backend
Bases: sage.repl.rich_output.backend_base.BackendBase
x.__init__(...) initializes x; see help(type(x)) for signature
Display object immediately
INPUT:
Same as displayhook().
EXAMPLES:
The following example does not call the displayhook. More precisely, the show() method returns None which is ignored by the displayhook. When running the example on a Sage display backend capable of displaying graphics outside of the displayhook, the plot is still shown. Nothing is shown during doctests:
sage: plt = plot(sin)
sage: plt
Graphics object consisting of 1 graphics primitive
sage: plt.show()
sage: from sage.repl.rich_output import get_display_manager
sage: dm = get_display_manager()
sage: dm.display_immediately(plt) # indirect doctest
Display object from displayhook
INPUT:
EXAMPLES:
This ends up calling the displayhook:
sage: plt = plot(sin)
sage: plt
Graphics object consisting of 1 graphics primitive
sage: plt.show()
sage: from sage.repl.rich_output import get_display_manager
sage: dm = get_display_manager()
sage: dm.displayhook(plt) # indirect doctest
Graphics object consisting of 1 graphics primitive
Switch to the the doctest backend
This method is being called from within switch_backend(). You should never call it by hand.
INPUT:
None of the optional keyword arguments are used in the doctest backend.
EXAMPLES:
sage: from sage.repl.rich_output.backend_doctest import BackendDoctest
sage: backend = BackendDoctest()
sage: backend.install()
sage: backend.uninstall()
Return the supported output types
OUTPUT:
Set of subclasses of OutputBase, the supported output container types.
EXAMPLES:
sage: from sage.repl.rich_output.backend_doctest import BackendDoctest
sage: from sage.repl.rich_output.output_catalog import *
sage: backend = BackendDoctest()
sage: OutputPlainText in backend.supported_output()
True
sage: OutputSceneJmol in backend.supported_output()
True
Switch away from the doctest backend
This method is being called from within switch_backend(). You should never call it by hand.
EXAMPLES:
sage: from sage.repl.rich_output.backend_doctest import BackendDoctest
sage: backend = BackendDoctest()
sage: backend.install()
sage: backend.uninstall()
Perform checks on rich_output
INPUT:
OUTPUT:
An assertion is triggered if rich_output is invalid.
EXAMPLES:
sage: from sage.repl.rich_output import get_display_manager
sage: dm = get_display_manager()
sage: invalid = dm.types.OutputImagePng('invalid')
sage: backend = dm._backend; backend
doctest
sage: backend.validate(invalid)
Traceback (most recent call last):
...
AssertionError
sage: backend.validate(dm.types.OutputPlainText.example())
sage: backend.validate(dm.types.OutputAsciiArt.example())
sage: backend.validate(dm.types.OutputLatex.example())
sage: backend.validate(dm.types.OutputImagePng.example())
sage: backend.validate(dm.types.OutputImageGif.example())
sage: backend.validate(dm.types.OutputImageJpg.example())
sage: backend.validate(dm.types.OutputImageSvg.example())
sage: backend.validate(dm.types.OutputImagePdf.example())
sage: backend.validate(dm.types.OutputImageDvi.example())
sage: backend.validate(dm.types.OutputSceneJmol.example())
sage: backend.validate(dm.types.OutputSceneWavefront.example())
sage: backend.validate(dm.types.OutputSceneCanvas3d.example())