What happened to Mathematica magics ?

91 views
Skip to first unread message

Emmanuel Charpentier

unread,
Feb 28, 2023, 10:03:24 AM2/28/23
to sage-devel

I don’t use them very often, bu the %mathematica and %%mathematica magics seem to have recently disappeared. They don’t appear in the %lsmagic output, and raise an error when one attempts to use them.

Can someone shed any light on this ?

John H Palmieri

unread,
Feb 28, 2023, 10:24:36 PM2/28/23
to sage-devel
I think it's due to https://github.com/sagemath/sage/issues/34547. That ticket was created because with the old behavior in Sage, instance of Octave(), Mathematica(), etc. were created when Sage started up, regardless of the availability of the corresponding software. Once those became lazy imports, they are apparently not detected by the code in sage/repl/interface_magic.py. We could restore the old non-lazy imports, or we could not be so clever about magic commands and define them manually, or there are probably other solutions.

The following sequence of commands seems to restore them, at least in the command line (haven't tested the notebook), if you want a short-term fix:

from sage.repl.interface_magic import InterfaceMagic
import sage.interfaces.all
sage.interfaces.all.__dict__
InterfaceMagic.register_all()

Emmanuel Charpentier

unread,
Mar 1, 2023, 3:09:41 AM3/1/23
to sage-devel
Thank you for the explanation.

The short-term fix works, but is noisy. Furthermore, it seems that it must be executed at toplevel : wrapping it in a function and calling this function doesn't work. So including it in a startup file doesn't seem reasonable.

The issue you pointed has been  closed on Jan 6, 2023. Do I need to create a new issue for this problem ?

BTW, diagnosting the problem is complicated by this issue, which seems to be at the bottom of the stack...

John H Palmieri

unread,
Mar 1, 2023, 1:57:42 PM3/1/23
to sage-devel
Yes, please create a new issue. You can cc me, but I don't know the best way to fix it.

I saw the other issue (that %lsmagic isn't helpful by default), but fortunately "%<TAB>" works. It would be great to fix this, too.

Emmanuel Charpentier

unread,
Mar 8, 2023, 4:22:18 AM3/8/23
to sage-devel

Done here.

Reply all
Reply to author
Forward
0 new messages