Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%lsmagic inoperative when display is text plain #30661

Open
EmmanuelCharpentier mannequin opened this issue Sep 25, 2020 · 2 comments
Open

%lsmagic inoperative when display is text plain #30661

EmmanuelCharpentier mannequin opened this issue Sep 25, 2020 · 2 comments

Comments

@EmmanuelCharpentier
Copy link
Mannequin

EmmanuelCharpentier mannequin commented Sep 25, 2020

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 :

  • in a terminal
  • in a Jupyter notebook
  • in a sage-shell-mode session in emacs

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

@EmmanuelCharpentier EmmanuelCharpentier mannequin added this to the sage-9.2 milestone Sep 25, 2020
@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Oct 24, 2020
@mkoeppe
Copy link
Member

mkoeppe commented May 10, 2021

comment:2

Moving to 9.4, as 9.3 has been released.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 May 10, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Aug 22, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 May 3, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Sep 19, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
@nbruin
Copy link
Contributor

nbruin commented Mar 2, 2023

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 repr_pretty (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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants