sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.33k stars 453 forks source link

%lsmagic inoperative when display is text plain #30661

Open 7822f248-ba56-45f1-ab3d-4de7482bdf9f opened 3 years ago

7822f248-ba56-45f1-ab3d-4de7482bdf9f commented 3 years ago

reported in this ask.sagemath question, this nice one

The line magic %lsmagic is inoperative when the display mode is the default "text plain", but works in other modes (tested ascii_art, unicode_art and latex):

sage: %display default                                                          
sage: %lsmagic                                                                  
<IPython.core.magics.basic.MagicsDisplay object at 0x7fa8fdfaa1f0>
sage: %display ascii_art                                                        
sage: %lsmagic                                                                  
Available line magics:
%alias  %alias_magic  %attach  %autoawait  %autocall  %autoindent  %automagic  %axiom  %bookmark  %cat  %cd  %clear  %colors  %conda  %config  %cp  %cpaste  %crun  %debug  %dhist  %dirs  %display  %doctest_mode  %ed  %edit  %env  %fricas  %gap  %gap3  %giac  %gp  %gui  %hist  %history  %iload  %kash  %killbgscripts  %ldir  %less  %lf  %lie  %lisp  %lk  %ll  %load  %load_ext  %loadpy  %logoff  %logon  %logstart  %logstate  %logstop  %ls  %lsmagic  %lx  %macaulay2  %macro  %magic  %magma  %man  %maple  %mathematica  %matlab  %matplotlib  %maxima  %mkdir  %more  %mupad  %mv  %mwrank  %notebook  %octave  %page  %paste  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2  %pip  %polymake  %popd  %pprint  %precision  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  %quickref  %r  %recall  %rehashx  %reload_ext  %rep  %rerun  %reset  %reset_selective  %rm  %rmdir  %run  %runfile  %sage0  %save  %sc  %scilab  %set_env  %singular  %store  %sx  %system  %tb  %time  %timeit  %unalias  %unload_ext  %who  %who_ls  %whos  %xdel  %xmode

Available cell magics:
%%!  %%HTML  %%SVG  %%axiom  %%bash  %%capture  %%cython  %%debug  %%file  %%fortran  %%fricas  %%gap  %%gap3  %%giac  %%gp  %%html  %%javascript  %%js  %%kash  %%latex  %%lie  %%lisp  %%macaulay2  %%magma  %%maple  %%markdown  %%mathematica  %%matlab  %%maxima  %%mupad  %%mwrank  %%octave  %%perl  %%polymake  %%prun  %%pypy  %%python  %%python2  %%python3  %%r  %%ruby  %%sage0  %%scilab  %%script  %%sh  %%singular  %%svg  %%sx  %%system  %%time  %%timeit  %%writefile

Automagic is ON, % prefix IS NOT needed for line magics.

This happens :

Switching back to %display default re-disables %lsmagic.

Disturbing...

Component: user interface

Keywords: IPython magics display

Issue created by migration from https://trac.sagemath.org/ticket/30661

mkoeppe commented 3 years ago
comment:2

Moving to 9.4, as 9.3 has been released.

nbruin commented 1 year ago

As far as I can see the problem here is that in .../local/var/lib/sage/venv-python3.10/lib64/python3.10/site-packages/IPython/core/magics/basic.py the class MagicsDisplay does not have a repr function. It does have a str function and a _reprpretty (which is probably why ascii_art works). It looks like this is upstream, so perhaps someone should check in the IPython devs would not mind including a repr.