A cell is a single input/output block. Worksheets are built out of a list of cells.
Bases: sagenb.notebook.cell.Cell_generic
Returns this compute cell’s output type.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.cell_output_type()
'wrap'
sage: C.set_cell_output_type('nowrap')
sage: C.cell_output_type()
'nowrap'
Returns the changed input text for this compute cell. If there is any changed input text, it is reset to ‘’ before this method returns.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.changed_input_text()
''
sage: C.set_changed_input_text('3+3')
sage: C.input_text()
u'3+3'
sage: C.changed_input_text()
u'3+3'
sage: C.changed_input_text()
''
sage: C.version()
0
Returns this compute cell’s “cleaned” input text, i.e., its input with all of its percent directives removed. If this cell is interacting, it returns the interacting text.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '%hide\n%maxima\n2+3', '5', None)
sage: C.cleaned_input_text()
u'2+3'
Returns whether this compute cell is queued for evaluation by its worksheet object.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "2^2")
sage: C.computing()
False
sage: nb.delete()
Deletes all of the files associated with this compute cell.
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, 'plot(sin(x),0,5)', '', W)
sage: C.evaluate()
sage: W.check_comp(wait=9999) # random output -- depends on computer speed
('d', Cell 0; in=plot(sin(x),0,5), out=
<html><font color='black'><img src='cell://sage0.png'></font></html>
<BLANKLINE>
)
sage: C.files() # random output -- depends on computer speed
['sage0.png']
sage: C.delete_files()
sage: C.files()
[]
sage: W.quit()
sage: nb.delete()
Deletes all output in this compute cell.
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None); C
Cell 0; in=2+3, out=5
sage: C.delete_output()
sage: C
Cell 0; in=2+3, out=
Returns the name of this compute cell’s directory, creating it, if it doesn’t already exist.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.directory()
'.../home/sage/0/cells/0'
sage: nb.delete()
Returns HTML for a doc browser cell. This is a modified version of :meth:html.
This is a hack and needs to be improved. The problem is how to get the documentation HTML to display nicely between the example cells. The type setting (jsMath formatting) needs attention too.
TODO: Remove this hack (doc_html())
INPUT:
OUTPUT:
Returns the text displayed for this compute cell in the Edit window.
INPUT:
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.edit_text()
u'{{{id=0|\n2+3\n///\n5\n}}}'
sage: C = sagenb.notebook.cell.Cell(0, 'ěščřžýáíéďĎ', 'ěščřžýáíéďĎ', None)
sage: C.edit_text()
u'{{{id=0|\něščřž\xfd\xe1\xed\xe9ďĎ\n///\něščřž\xfd\xe1\xed\xe9ďĎ\n}}}'
Evaluates this compute cell.
INPUT:
after_cursor] of strings (default: False)
time - a boolean (default: None); whether to return the time the computation takes
the evaluation
EXAMPLES:
We create a notebook, worksheet, and cell and evaluate it in order to compute :
sage: nb = sagenb.notebook.notebook.load_notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: W.edit_save('{{{\n3^5\n}}}')
sage: C = W.cell_list()[0]; C
Cell 0; in=3^5, out=
sage: C.evaluate(username='sage')
sage: W.check_comp(wait=9999) # random output -- depends on computer speed
('d', Cell 0; in=3^5, out=
243
)
sage: C # random output -- depends on computer speed
Cell 0; in=3^5, out=
243
sage: W.quit()
sage: nb.delete()
Returns whether this compute cell has been successfully evaluated in a currently running session. This is not about whether the output of the cell is valid given the input.
OUTPUT:
EXAMPLES: We create a worksheet with a cell that has wrong output:
sage: nb = sagenb.notebook.notebook.load_notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: W.edit_save('{{{\n2+3\n///\n20\n}}}')
sage: C = W.cell_list()[0]
sage: C
Cell 0; in=2+3, out=
20
We re-evaluate that input cell:
sage: C.evaluate()
sage: W.check_comp(wait=9999) # random output -- depends on computer speed
('w', Cell 0; in=2+3, out=)
Now the output is right:
sage: C # random output -- depends on computer speed
Cell 0; in=2+3, out=
And the cell is considered to have been evaluated.
sage: C.evaluated() # random output -- depends on computer speed
True
sage: W.quit()
sage: nb.delete()
Returns a list of all the files in this compute cell’s directory.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, 'plot(sin(x),0,5)', '', W)
sage: C.evaluate()
sage: W.check_comp(wait=9999) # random output -- depends on computer speed
('d', Cell 0; in=plot(sin(x),0,5), out=
<html><font color='black'><img src='cell://sage0.png'></font></html>
<BLANKLINE>
)
sage: C.files() # random output -- depends on computer speed
['sage0.png']
sage: W.quit()
sage: nb.delete()
Returns HTML to display the files in this compute cell’s directory.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, 'plot(sin(x),0,5)', '', W)
sage: C.evaluate()
sage: W.check_comp(wait=9999) # random output -- depends on computer speed
('d', Cell 0; in=plot(sin(x),0,5), out=
<html><font color='black'><img src='cell://sage0.png'></font></html>
<BLANKLINE>
)
sage: C.files_html('') # random output -- depends on computer speed
'<img src="/home/sage/0/cells/0/sage0.png?...">'
sage: W.quit()
sage: nb.delete()
Returns whether this compute cell has any output.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.has_output()
True
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '', None)
sage: C.has_output()
False
Returns the HTML for this compute cell.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.load_notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.html()
u'...cell_outer_0...2+3...5...'
Returns this compute cell’s ID.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.id()
0
Returns this compute cell’s input text.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.input_text()
u'2+3'
Sets this compute cell’s evaluation as interrupted.
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "2^2")
sage: C.interrupt()
sage: C.interrupted()
True
sage: C.evaluated()
False
sage: nb.delete()
Returns whether this compute cell’s evaluation has been interrupted.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "2^2")
sage: C.interrupt()
sage: C.interrupted()
True
sage: nb.delete()
Returns compute cell’s introspection text.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, 'sage?', '', W)
sage: C.introspect()
False
sage: C.evaluate(username='sage')
sage: W.check_comp(9999) # random output -- depends on computer speed
('d', Cell 0; in=sage?, out=)
sage: C.introspect()
[u'sage?', '']
sage: W.quit()
sage: nb.delete()
Returns this compute cell’s introspection text, setting it to ‘’, if none is available.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, 'sage?', '', W)
sage: C.introspect()
False
sage: C.evaluate(username='sage')
sage: W.check_comp(9999) # random output -- depends on computer speed
('d', Cell 0; in=sage?, out=)
sage: C.introspect_html() # random output -- depends on computer speed
u'...<div class="docstring">...sage...</pre></div>...'
sage: W.quit()
sage: nb.delete()
Returns whether this compute cell is to be evaluated as soon as possible (ASAP).
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.is_asap()
False
sage: C.set_asap(True)
sage: C.is_asap()
True
Returns whether this compute cell is evaluated automatically when its worksheet object starts up.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.is_auto_cell()
False
sage: C = sagenb.notebook.cell.Cell(0, '#auto\n2+3', '5', None)
sage: C.is_auto_cell()
True
Returns whether this is an HTML compute cell, e.g., its system is ‘html’. This is typically specified by the percent directive %html.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, "%html\nTest HTML", None, None)
sage: C.system()
u'html'
sage: C.is_html()
True
sage: C = sagenb.notebook.cell.Cell(0, "Test HTML", None, None)
sage: C.is_html()
False
Returns whether this compute cell is currently sagenb.notebook.interact.interact()ing.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "@interact\ndef f(a=slider(0,10,1,5):\n print a^2")
sage: C.is_interacting()
False
Returns whether this compute cell contains sagenb.notebook.interact.interact() either as a function call or decorator.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "@interact\ndef f(a=slider(0,10,1,5):\n print a^2")
sage: C.is_interactive_cell()
True
sage: C = W.new_cell_after(C.id(), "2+2")
sage: C.is_interactive_cell()
False
sage: nb.delete()
Returns whether this compute cell is the last cell in its worksheet object.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "2^2"); C
Cell 2; in=2^2, out=
sage: C.is_last()
True
sage: C = W.get_cell_with_id(0)
sage: C.is_last()
False
sage: nb.delete()
Returns whether this is a “no output” compute cell, i.e., we don’t care about its output.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.is_no_output()
False
sage: C.set_no_output(True)
sage: C.is_no_output()
True
Returns the ID of the next cell in this compute cell’s worksheet object. If this cell is not in the worksheet or is the last cell, it returns the ID of the worksheet’s first cell.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(1, "2^2")
sage: C = W.get_cell_with_id(1)
sage: C.next_id()
2
sage: C = W.get_cell_with_id(2)
sage: C.next_id()
1
sage: nb.delete()
Returns this compute cell’s associated notebook object.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.load_notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.notebook() is nb
True
sage: nb.delete()
Returns this compute cell’s HTML output.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.output_html()
''
sage: C.set_output_text('5', '<strong>5</strong>')
sage: C.output_html()
u'<strong>5</strong>'
Returns this compute cell’s output text.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.output_text()
u'<pre class="shrunk">5</pre>'
sage: C.output_text(html=False)
u'<pre class="shrunk">5</pre>'
sage: C.output_text(raw=True)
u'5'
sage: C = sagenb.notebook.cell.Cell(0, 'ěščřžýáíéďĎ', 'ěščřžýáíéďĎ', W)
sage: C.output_text()
u'<pre class="shrunk">ěščřž\xfd\xe1\xed\xe9ďĎ</pre>'
sage: C.output_text(raw=True)
u'ěščřž\xfd\xe1\xed\xe9ďĎ'
Parses HTML for output, escaping and wrapping HTML and removing script elements.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.parse_html('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">\n<html><head></head><body>Test</body></html>', 80)
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0...Test</body>'
Parses this compute cell’s percent directives, determines its system (if any), and returns the “cleaned” input text.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '%hide\n%maxima\n%pi+3', '5', None)
sage: C.parse_percent_directives()
u'%pi+3'
sage: C.percent_directives()
[u'hide', u'maxima']
Returns a list of this compute cell’s percent directives.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '%hide\n%maxima\n2+3', '5', None)
sage: C.percent_directives()
[u'hide', u'maxima']
Returns the plain text version of this compute cell.
INPUT:
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: len(C.plain_text())
11
Processes this compute cell’s 'cell://.*?' URLs, replacing the protocol with the cell’s path and appending the cell’s version number.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.process_cell_urls('"cell://foobar"')
'/home/sage/0/cells/0/foobar?0'
Returns the sage instance for this compute cell(?).
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.sage() is None
True
Sets whether to evaluate this compute cell as soon as possible (ASAP).
INPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.is_asap()
False
sage: C.set_asap(True)
sage: C.is_asap()
True
Sets this compute cell’s output type.
INPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.cell_output_type()
'wrap'
sage: C.set_cell_output_type('nowrap')
sage: C.cell_output_type()
'nowrap'
Updates this compute cell’s changed input text. Note: This does not update the version of the cell. It’s typically used, e.g., for tab completion.
INPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.set_changed_input_text('3+3')
sage: C.input_text()
u'3+3'
sage: C.changed_input_text()
u'3+3'
Sets this compute cell’s ID.
INPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.set_id(2)
sage: C.id()
2
Sets the input text of this compute cell.
INPUT:
TODO: Add doctests for the code dealing with interact.
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = W.new_cell_after(0, "2^2")
sage: C.evaluate()
sage: W.check_comp(wait=9999) # random output -- depends on computer speed
('d', Cell 1; in=2^2, out=
4
)
sage: C.version()
0
sage: C.set_input_text('3+3')
sage: C.input_text()
u'3+3'
sage: C.evaluated()
False
sage: C.version()
1
sage: W.quit()
sage: nb.delete()
Set this compute cell’s introspection text.
INPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.set_introspect("a", "b")
sage: C.introspect()
['a', 'b']
Sets this compute cell’s introspection text.
INPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, 'sage?', '', W)
sage: C.introspect()
False
sage: C.evaluate(username='sage')
sage: W.check_comp(9999) # random output -- depends on computer speed
('d', Cell 0; in=sage?, out=)
sage: C.set_introspect_html('foobar')
sage: C.introspect_html()
u'foobar'
sage: C.set_introspect_html('`foobar`')
sage: C.introspect_html()
u'`foobar`'
sage: C.set_introspect_html('ěščřžýáíéďĎ')
sage: C.introspect_html()
u'ěščřž\xfd\xe1\xed\xe9ďĎ'
sage: W.quit()
sage: nb.delete()
Sets whether this is a “no output” compute cell, i.e., we don’t care about its output.
INPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.is_no_output()
False
sage: C.set_no_output(True)
sage: C.is_no_output()
True
Sets this compute cell’s output text.
INPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: len(C.plain_text())
11
sage: C.set_output_text('10', '10')
sage: len(C.plain_text())
12
Sets this compute cell’s worksheet object and, optionally, its ID.
INPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: W = "worksheet object"
sage: C.set_worksheet(W)
sage: C.worksheet()
'worksheet object'
sage: C.set_worksheet(None, id=2)
sage: C.id()
2
Stops sagenb.notebook.interact.interact()ion for this compute cell.
TODO: Add doctests.
Returns the system used to evaluate this compute cell. The system is specified by a percent directive like ‘%maxima’ at the top of a cell.
Returns None, if no system is explicitly specified. In this case, the notebook evaluates the cell using the worksheet’s default system.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '%maxima\n2+3', '5', None)
sage: C.system()
u'maxima'
sage: prefixes = ['%hide', '%time', '']
sage: cells = [sagenb.notebook.cell.Cell(0, '%s\n2+3'%prefix, '5', None) for prefix in prefixes]
sage: [(C, C.system()) for C in cells if C.system() is not None]
[]
Returns whether to print timing information about the evaluation of this compute cell.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.time()
False
sage: C = sagenb.notebook.cell.Cell(0, '%time\n2+3', '5', None)
sage: C.time()
True
Clears this compute cell’s introspection text.
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, 'sage?', '', W)
sage: C.introspect()
False
sage: C.evaluate(username='sage')
sage: W.check_comp(9999) # random output -- depends on computer speed
('d', Cell 0; in=sage?, out=)
sage: C.introspect()
[u'sage?', '']
sage: C.unset_introspect()
sage: C.introspect()
False
sage: W.quit()
sage: nb.delete()
Updates this compute cell’s the file list with HTML-style links or embeddings.
For interactive cells, the HTML output section is always empty, mainly because there is no good way to distinguish content (e.g., images in the current directory) that goes into the interactive template and content that would go here.
INPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, 'plot(sin(x),0,5)', '', W)
sage: C.evaluate()
sage: W.check_comp(wait=9999) # random output -- depends on computer speed
('d', Cell 0; in=plot(sin(x),0,5), out=
<html><font color='black'><img src='cell://sage0.png'></font></html>
<BLANKLINE>
)
sage: C.update_html_output()
sage: C.output_html() # random output -- depends on computer speed
'<img src="/home/sage/0/cells/0/sage0.png?...">'
sage: W.quit()
sage: nb.delete()
Returns a notebook URL for this compute cell.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.url_to_self()
'/home/sage/0/cells/0'
Returns this compute cell’s version number.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.version()
0
sage: C.set_input_text('2+3')
sage: C.version()
1
Returns the number of columns for word wrapping this compute cell. This defaults to 70, but the default setting for a notebook is 72.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', None)
sage: C.word_wrap_cols()
70
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.word_wrap_cols()
72
sage: nb.delete()
Returns this compute cell’s worksheet object.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.worksheet() is W
True
sage: nb.delete()
Returns the filename of this compute cell’s worksheet object.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.Cell(0, '2+3', '5', W)
sage: C.worksheet_filename()
'sage/0'
sage: nb.delete()
Delete all output in this cell. This is not executed - it is an abstract function that must be overwritten in a derived class.
EXAMPLES:
This function just raises a NotImplementedError, since it must be defined in a derived class.
sage: C = sagenb.notebook.cell.Cell_generic()
sage: C.delete_output()
...
NotImplementedError
Returns whether this cell uses sagenb.notebook.interact.interact() as a function call or decorator.
OUTPUT:
EXAMPLES:
sage: from sagenb.notebook.cell import Cell_generic
sage: C = sagenb.notebook.cell.TextCell(0, '2+3', None)
sage: Cell_generic.is_interactive_cell(C)
False
Bases: sagenb.notebook.cell.Cell_generic
Delete all output in this text cell. This does nothing since text cells have no output.
EXAMPLES:
sage: C = sagenb.notebook.cell.TextCell(0, '2+3', None)
sage: C
TextCell 0: 2+3
sage: C.delete_output()
sage: C
TextCell 0: 2+3
Returns the text to be displayed for this text cell in the Edit window.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.TextCell(0, '2+3', None)
sage: C.edit_text()
u'2+3'
Returns HTML code for this text cell, including its contents and associated script elements.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir()+'.sagenb')
sage: nb.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.create_new_worksheet('Test', 'sage')
sage: C = sagenb.notebook.cell.TextCell(0, '2+3', W)
sage: C.html()
u'...text_cell...2+3...'
sage: C.set_input_text("$2+3$")
sage: C.html(do_math_parse=True)
u'...text_cell...class="math"...2+3...'
Returns this text cell’s ID.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.TextCell(0, '2+3', None)
sage: C.id()
0
Returns whether this is an automatically evaluated text cell. This is always false for TextCells.
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.TextCell(0, '2+3', None)
sage: C.is_auto_cell()
False
Returns a plain text version of this ext cell.
INPUT:
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.TextCell(0, '2+3', None)
sage: C.plain_text()
u'2+3'
sage: C = sagenb.notebook.cell.TextCell(0, 'ěščřžýáíéďĎ', None)
sage: C.plain_text()
u'ěščřž\xfd\xe1\xed\xe9ďĎ'
Sets this text cell’s output type. This does nothing for TextCells.
INPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.TextCell(0, '2+3', None)
sage: C.set_cell_output_type("wrap")
Sets the input text of this text cell.
INPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.TextCell(0, '2+3', None)
sage: C
TextCell 0: 2+3
sage: C.set_input_text("3+2")
sage: C
TextCell 0: 3+2
Updates this text cell’s worksheet object and, optionally, its ID.
INPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.TextCell(0, '2+3', None)
sage: W = "worksheet object"
sage: C.set_worksheet(W)
sage: C.worksheet()
'worksheet object'
sage: C.set_worksheet(None, id=2)
sage: C.id()
2
Returns this text cell’s worksheet object
OUTPUT:
EXAMPLES:
sage: C = sagenb.notebook.cell.TextCell(0, '2+3', 'worksheet object')
sage: C.worksheet()
'worksheet object'
Formats exceptions so they do not appear expanded by default.
INPUT:
OUTPUT:
If s0 contains “notracebacks,” this function simply returns s0.
EXAMPLES:
sage: sagenb.notebook.cell.format_exception(sagenb.notebook.cell.TRACEBACK,80)
'\nTraceback (click to the left of this block for traceback)\n...\nTraceback (most recent call last):'
sage: sagenb.notebook.cell.format_exception(sagenb.notebook.cell.TRACEBACK + "notracebacks",80)
'Traceback (most recent call last):notracebacks'
Returns the number of rows needed to display a string, given a maximum number of columns per row.
INPUT:
OUTPUT:
EXAMPLES:
sage: from sagenb.notebook.cell import number_of_rows
sage: s = "asdfasdf\nasdfasdf\n"
sage: number_of_rows(s, 8)
2
sage: number_of_rows(s, 5)
4
sage: number_of_rows(s, 4)
4