evaluate all input cells from command line

11 views
Skip to first unread message

ma...@mendelu.cz

unread,
Feb 10, 2010, 5:16:35 AM2/10/10
to sage-notebook
Dear members of sage-notebook

I looked a bit at tex2sws converter.

I wonder how can I evaluate all cells in notebook

sage: from sagenb.notebook.notebook import Notebook
sage: nb=Notebook('./a.sagenb')
sage: nb.add_user('sage','sage','nob...@nowhere.cz',force=True)
sage: W=nb.create_new_worksheet('Test','sage')
sage: W.edit_save('{{{\n2+3\n///456\n}}}\n{{{\n10-9\n///444\n}}}')
sage: W
sage/0: [Cell 0; in=2+3, out=456, Cell 1; in=10-9, out=444]


Now I want to evaluate all input cells to get correct answers. I have
seem something relevant at the end of sagenb/testing/tests/
test_worksheet.py but I do not know hot to use it in console version
of Sage.

Thanks for answers

Robert Marik

ma...@mendelu.cz

unread,
Feb 10, 2010, 10:17:03 AM2/10/10
to sage-notebook
I'll answer my own question


[marik@um-bc107 /opt/sage]$ ./sage
----------------------------------------------------------------------
| Sage Version 4.3.2, Release Date: 2010-02-06 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: nb = sagenb.notebook.notebook.load_notebook('/tmp/weewr.sagenb')


sage: nb.add_user('sage','sage','nob...@nowhere.cz',force=True)

sage: W=nb.create_new_worksheet('Pokus','sage')
sage: W.edit_save('{{{\n2+3\n///\n}}}\n{{{\n10-9\n///\n}}}')
sage: W
sage/0: [Cell 0; in=2+3, out=, Cell 1; in=10-9, out=]
sage: W.cell_list()[1].evaluate()
sage: W.check_comp()
('d', Cell 1; in=10-9, out=
1
)
sage: W
sage/0: [Cell 0; in=2+3, out=, Cell 1; in=10-9, out=
1
]
sage: W.cell_list()[0].evaluate()
sage: W.check_comp()
('d', Cell 0; in=2+3, out=
5


)
sage: W
sage/0: [Cell 0; in=2+3, out=

5
, Cell 1; in=10-9, out=
1
]
sage:

Rob Beezer

unread,
Feb 10, 2010, 10:34:58 PM2/10/10
to sage-notebook
Robert,

Good to know. Something I want to investigate is using SageTeX for
this sort of thing. Run SageTeX to get Sage to create output cells
where desired, then have that output included in the conversion
process to a worksheet. Just not sure where the runs of SageTeX and
the runs of tex4ht belong in relation to each other.

I'm thinking at the moment that conversion to a Sage worksheet could
totally be a sage-notebook function, that doesn't need to rely on Sage
for anything during the conversion. Maybe.

Rob

Reply all
Reply to author
Forward
0 new messages