Skip to content

Commit 0447579

Browse files
committed
Add a test for view-annotate=displayhtml
1 parent 0c152a1 commit 0447579

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/sage/repl/ipython_extension.py

+36
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,12 @@ def cython(self, line, cell):
350350
This is syntactic sugar on the
351351
:func:`~sage.misc.cython.cython_compile` function.
352352
353+
Note that there is also the ``%%cython`` cell magic provided by Cython,
354+
which can be loaded with ``%load_ext cython``, see
355+
`Cython documentation <https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#compiling-with-a-jupyter-notebook>`_
356+
for more details.
357+
The semantic is slightly different from the version provided by Sage.
358+
353359
INPUT:
354360
355361
- ``line`` -- parsed as keyword arguments. The allowed arguments are:
@@ -425,6 +431,36 @@ def cython(self, line, cell):
425431
....: ''')
426432
UsageError: argument --view-annotate: invalid choice: 'xx' (choose from 'none', 'auto', 'webbrowser', 'displayhtml')
427433
434+
Test ``--view-annotate=displayhtml`` (note that in a notebook environment
435+
an inline HTML frame will be displayed)::
436+
437+
sage: # needs sage.misc.cython
438+
sage: shell.run_cell('''
439+
....: %%cython --view-annotate=displayhtml
440+
....: print(1)
441+
....: ''')
442+
1
443+
<IPython.core.display.HTML object>
444+
445+
Test ``--view-annotate=webbrowser``::
446+
447+
sage: # needs sage.misc.cython webbrowser
448+
sage: shell.run_cell('''
449+
....: %%cython --view-annotate
450+
....: print(1)
451+
....: ''')
452+
1
453+
sage: shell.run_cell('''
454+
....: %%cython --view-annotate=auto
455+
....: print(1)
456+
....: ''')
457+
1
458+
sage: shell.run_cell('''
459+
....: %%cython --view-annotate=webbrowser
460+
....: print(1)
461+
....: ''')
462+
1
463+
428464
Test invalid quotes (see :mod:`sage.repl.interpreter` for explanation of the dummy line)::
429465
430466
sage: # needs sage.misc.cython

0 commit comments

Comments
 (0)