Support for the Notebook (introspection and setup)

AUTHORS:

  • William Stein (much of this code is from IPython).
sage.server.support._is_new_var(x, v)
sage.server.support.completions(s, globs, format=False, width=90, system='None')
Return a list of completions in the context of globs.
sage.server.support.cython_import(filename, verbose=False, compile_message=False, use_cache=False, create_local_c_file=True)

INPUT:

  • filename - name of a file that contains cython code

OUTPUT:

  • module - the module that contains the compiled cython code.

Raises an ImportError exception if anything goes wrong.

sage.server.support.cython_import_all(filename, globals, verbose=False, compile_message=False, use_cache=False, create_local_c_file=True)

INPUT:

  • filename - name of a file that contains cython code

OUTPUT: changes globals using the attributes of the Cython module that do not begin with an underscore.

Raises an ImportError exception if anything goes wrong.

sage.server.support.docstring(obj_name, globs, system='sage')

Format obj_name‘s docstring for printing in Sage notebook.

AUTHORS:

  • William Stein: partly taken from IPython for use in Sage
  • Nick Alexander: extensions
sage.server.support.get_rightmost_identifier(s)
sage.server.support.help(obj)

Display help on s.

Note

This a wrapper around the built-in help. If formats the output as HTML without word wrap, which looks better in the notebook.

INPUT:

  • s - Python object, module, etc.

OUTPUT: prints out help about s; it’s often more more extensive than foo?

TESTS:

sage: import numpy.linalg
sage: import os, sage.misc.misc ; current_dir = os.getcwd()
sage: os.chdir(sage.misc.misc.tmp_dir('server_doctest'))
sage: sage.server.support.help(numpy.linalg.norm)
<html><table notracebacks bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d">
&nbsp;&nbsp;&nbsp;<a target='_new' href='cell://docs-....html'>Click to open help window</a>&nbsp;&nbsp;&nbsp;
<br></font></tr></td></table></html>
sage: os.chdir(current_dir)
sage.server.support.init(object_directory=None, globs={})
Initialize Sage for use with the web notebook interface.
sage.server.support.load_session(v, filename, state)
sage.server.support.save_session(filename)
sage.server.support.setup_systems(globs)
sage.server.support.source_code(s, globs, system='sage')

Format obj’s source code for printing in Sage notebook.

AUTHORS:

  • William Stein: partly taken from IPython for use in Sage
  • Nick Alexander: extensions
sage.server.support.syseval(system, cmd, dir=None)
INPUT:
system – an object with an eval method that takes as input
a cmd (a string), and two dictionaries:
sage_globals and locals.
dir – an optional directory to change to before
calling system.eval.
OUTPUT:
The output of system.eval is returned.
EXAMPLES:
sage: from sage.misc.python import python sage: sage.server.support.syseval(python, ‘2+4/3’) 3 ‘’ sage: sage.server.support.syseval(python, ‘import os; os.chdir(“.”)’) ‘’ sage: sage.server.support.syseval(python, ‘import os; os.chdir(1,2,3)’) Traceback (most recent call last): ... TypeError: chdir() takes exactly 1 argument (3 given) sage: sage.server.support.syseval(gap, “2+3”) ‘5’
sage.server.support.tabulate(v, width=90, ncols=3)
sage.server.support.variables(with_types=True)

Previous topic

Sage Notebook CSS

Next topic

Sage Notebook: Introspection

This Page