From 04475791d35c9c1007ae9b2609b9079bc7910767 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Thu, 12 Dec 2024 21:14:11 +0700 Subject: [PATCH] Add a test for view-annotate=displayhtml --- src/sage/repl/ipython_extension.py | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/sage/repl/ipython_extension.py b/src/sage/repl/ipython_extension.py index f31a24d553a..3f013d628ff 100644 --- a/src/sage/repl/ipython_extension.py +++ b/src/sage/repl/ipython_extension.py @@ -350,6 +350,12 @@ def cython(self, line, cell): This is syntactic sugar on the :func:`~sage.misc.cython.cython_compile` function. + Note that there is also the ``%%cython`` cell magic provided by Cython, + which can be loaded with ``%load_ext cython``, see + `Cython documentation `_ + for more details. + The semantic is slightly different from the version provided by Sage. + INPUT: - ``line`` -- parsed as keyword arguments. The allowed arguments are: @@ -425,6 +431,36 @@ def cython(self, line, cell): ....: ''') UsageError: argument --view-annotate: invalid choice: 'xx' (choose from 'none', 'auto', 'webbrowser', 'displayhtml') + Test ``--view-annotate=displayhtml`` (note that in a notebook environment + an inline HTML frame will be displayed):: + + sage: # needs sage.misc.cython + sage: shell.run_cell(''' + ....: %%cython --view-annotate=displayhtml + ....: print(1) + ....: ''') + 1 + + + Test ``--view-annotate=webbrowser``:: + + sage: # needs sage.misc.cython webbrowser + sage: shell.run_cell(''' + ....: %%cython --view-annotate + ....: print(1) + ....: ''') + 1 + sage: shell.run_cell(''' + ....: %%cython --view-annotate=auto + ....: print(1) + ....: ''') + 1 + sage: shell.run_cell(''' + ....: %%cython --view-annotate=webbrowser + ....: print(1) + ....: ''') + 1 + Test invalid quotes (see :mod:`sage.repl.interpreter` for explanation of the dummy line):: sage: # needs sage.misc.cython