def matlab_console(): """ This requires that the optional matlab program be installed and in your PATH, but no optional Sage packages need be installed. EXAMPLES:: sage: matlab_console() # optional - matlab; not tested < M A T L A B > Copyright 1984-2006 The MathWorks, Inc. ... >> 2+3 ans = 5 quit Typing quit exits the matlab console and returns you to Sage. matlab, like Sage, remembers its history from one session to another. """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%matlab magics instead.') os.system('matlab -nodisplay')
def kash_console(): from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError( 'Can use the console only in the terminal. Try %%kash magics instead.' ) os.system("kash3 ")
def octave_console(): """ Spawn a new Octave command-line session. This requires that the optional octave program be installed and in your PATH, but no optional Sage packages need be installed. EXAMPLES:: sage: octave_console() # not tested GNU Octave, version 2.1.73 (i386-apple-darwin8.5.3). Copyright (C) 2006 John W. Eaton. ... octave:1> 2+3 ans = 5 octave:2> [ctl-d] Pressing ctrl-d exits the octave console and returns you to Sage. octave, like Sage, remembers its history from one session to another. """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%octave magics instead.') os.system('octave-cli')
def octave_console(): """ Spawn a new Octave command-line session. This requires that the optional octave program be installed and in your PATH, but no optional Sage packages need be installed. EXAMPLES:: sage: octave_console() # not tested GNU Octave, version 2.1.73 (i386-apple-darwin8.5.3). Copyright (C) 2006 John W. Eaton. ... octave:1> 2+3 ans = 5 octave:2> [ctl-d] Pressing ctrl-d exits the octave console and returns you to Sage. octave, like Sage, remembers its history from one session to another. """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError( 'Can use the console only in the terminal. Try %%octave magics instead.' ) os.system('octave')
def __init__(self, *args, **kwds): """ This is where the Sage rich objects are translated to IPython INPUT/OUTPUT: See the IPython documentation. EXAMPLES: This is part of how Sage works with the IPython output system. It cannot be used in doctests:: sage: from sage.repl.display.formatter import SageDisplayFormatter sage: fmt = SageDisplayFormatter() Traceback (most recent call last): ... RuntimeError: check failed: current backend is invalid """ super(SageDisplayFormatter, self).__init__(*args, **kwds) from sage.repl.rich_output.display_manager import get_display_manager self.dm = get_display_manager() from sage.repl.rich_output.backend_ipython import BackendIPython self.dm.check_backend_class(BackendIPython) pt_formatter = self.formatters[PLAIN_TEXT] pt_formatter.observe(self._ipython_float_precision_changed, names=['float_precision'])
def matlab_console(): """ This requires that the optional matlab program be installed and in your PATH, but no optional Sage packages need be installed. EXAMPLES:: sage: matlab_console() # optional - matlab; not tested < M A T L A B > Copyright 1984-2006 The MathWorks, Inc. ... >> 2+3 ans = 5 quit Typing quit exits the matlab console and returns you to Sage. matlab, like Sage, remembers its history from one session to another. """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError( 'Can use the console only in the terminal. Try %%matlab magics instead.' ) os.system('matlab -nodisplay')
def gnuplot_console(): from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError( 'Can use the console only in the terminal. Try %%gnuplot magics instead.' ) os.system('sage-native-execute gnuplot')
def mwrank_console(): """ Start the mwrank console. EXAMPLE:: sage: mwrank_console() # not tested: expects console input Program mwrank: ... """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%mwrank magics instead.') os.system('mwrank')
def mwrank_console(): """ Start the mwrank console. EXAMPLE:: sage: mwrank_console() # not tested: expects console input Program mwrank: ... """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%mwrank magics instead.') os.system('mwrank')
def macaulay2_console(): """ Spawn a new M2 command-line session. EXAMPLES:: sage: macaulay2_console() # not tested Macaulay 2, version 1.1 with packages: Classic, Core, Elimination, IntegralClosure, LLLBases, Parsing, PrimaryDecomposition, SchurRings, TangentCone ... """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%macaulay2 magics instead.') os.system('M2')
def gp_console(): """ Spawn a new GP command-line session. EXAMPLES:: sage: gp.console() # not tested GP/PARI CALCULATOR Version 2.4.3 (development svn-12577) amd64 running linux (x86-64/GMP-4.2.1 kernel) 64-bit version compiled: Jul 21 2010, gcc-4.6.0 20100705 (experimental) (GCC) (readline v6.0 enabled, extended help enabled) """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%gp magics instead.') os.system('gp')
def gp_console(): """ Spawn a new GP command-line session. EXAMPLES:: sage: gp.console() # not tested GP/PARI CALCULATOR Version 2.4.3 (development svn-12577) amd64 running linux (x86-64/GMP-4.2.1 kernel) 64-bit version compiled: Jul 21 2010, gcc-4.6.0 20100705 (experimental) (GCC) (readline v6.0 enabled, extended help enabled) """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%gp magics instead.') os.system('gp')
def macaulay2_console(): """ Spawn a new M2 command-line session. EXAMPLES:: sage: macaulay2_console() # not tested Macaulay 2, version 1.1 with packages: Classic, Core, Elimination, IntegralClosure, LLLBases, Parsing, PrimaryDecomposition, SchurRings, TangentCone ... """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%macaulay2 magics instead.') os.system('M2')
def sage0_console(): """ Spawn a new Sage command-line session. EXAMPLES:: sage: sage0_console() #not tested ---------------------------------------------------------------------- | SageMath version ..., Release Date: ... | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- ... """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%sage0 magics instead.') os.system('sage')
def line_magic_factory(self): """ Factory for line magic OUTPUT: A function suitable to be used as line magic. EXAMPLES:: sage: from sage.repl.interface_magic import InterfaceMagic sage: line_magic = InterfaceMagic.find('gap').line_magic_factory() sage: output = line_magic('1+1') sage: output 2 sage: type(output) <class 'sage.interfaces.gap.GapElement'> This is how the built line magic is used in practice:: sage: from sage.repl.interpreter import get_test_shell sage: shell = get_test_shell() sage: shell.run_cell('%gap 1+1') 2 sage: shell.run_cell('%gap?') Docstring: Interact with gap <BLANKLINE> The line magic %gap sends a single line to the gap interface. ... """ terminal = get_display_manager().is_in_terminal() def line_magic(line): if line: return self._interface(line) else: if terminal: self._interface.interact() else: raise SyntaxError('{0} command required'.format( self._name)) line_magic.__doc__ = LINE_DOCSTRING.format(name=self._name) return line_magic
def lie_console(): """ Spawn a new LiE command-line session. EXAMPLES:: sage: from sage.interfaces.lie import lie_console sage: lie_console() # not tested LiE version 2.2.2 created on Sep 26 2007 at 18:13:19 Authors: Arjeh M. Cohen, Marc van Leeuwen, Bert Lisser. Free source code distribution ... """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%lie magics instead.') os.system('bash `which lie`')
def lie_console(): """ Spawn a new LiE command-line session. EXAMPLES:: sage: from sage.interfaces.lie import lie_console sage: lie_console() # not tested LiE version 2.2.2 created on Sep 26 2007 at 18:13:19 Authors: Arjeh M. Cohen, Marc van Leeuwen, Bert Lisser. Free source code distribution ... """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%lie magics instead.') os.system('bash `which lie`')
def maple_console(): r""" Spawn a new Maple command-line session. EXAMPLES:: sage: maple_console() #not tested |^/| Maple 11 (IBM INTEL LINUX) ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2007 \ MAPLE / All rights reserved. Maple is a trademark of <____ ____> Waterloo Maple Inc. | Type ? for help. > """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%maple magics instead.') os.system('maple')
def maple_console(): """ Spawn a new Maple command-line session. EXAMPLES:: sage: maple_console() #not tested |^/| Maple 11 (IBM INTEL LINUX) ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2007 \ MAPLE / All rights reserved. Maple is a trademark of <____ ____> Waterloo Maple Inc. | Type ? for help. > """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%maple magics instead.') os.system('maple')
def giac_console(): """ Spawn a new Giac command-line session. EXAMPLES:: sage: giac.console() # not tested - giac ... Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html Released under the GPL license 3.0 or above See http://www.gnu.org for license details ------------------------------------------------- Press CTRL and D simultaneously to finish session Type ?commandname for help """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%giac magics instead.') os.system('giac')
def giac_console(): """ Spawn a new Giac command-line session. EXAMPLES:: sage: giac.console() # not tested - giac ... Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html Released under the GPL license 3.0 or above See http://www.gnu.org for license details ------------------------------------------------- Press CTRL and D simultaneously to finish session Type ?commandname for help """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%giac magics instead.') os.system('giac')
def line_magic_factory(self): """ Factory for line magic OUTPUT: A function suitable to be used as line magic. EXAMPLES:: sage: from sage.repl.interface_magic import InterfaceMagic sage: line_magic = InterfaceMagic.find('gap').line_magic_factory() sage: output = line_magic('1+1') sage: output 2 sage: type(output) <class 'sage.interfaces.gap.GapElement'> This is how the built line magic is used in practice:: sage: from sage.repl.interpreter import get_test_shell sage: shell = get_test_shell() sage: shell.run_cell('%gap 1+1') 2 sage: shell.run_cell('%gap?') Docstring: Interact with gap <BLANKLINE> The line magic %gap sends a single line to the gap interface. ... """ terminal = get_display_manager().is_in_terminal() def line_magic(line): if line: return self._interface(line) else: if terminal: self._interface.interact() else: raise SyntaxError('{0} command required'.format(self._name)) line_magic.__doc__ = LINE_DOCSTRING.format(name=self._name) return line_magic
def lisp_console(): """ Spawn a new Lisp command-line session. EXAMPLES:: sage: lisp.console() #not tested ECL (Embeddable Common-Lisp) ... Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya Copyright (C) 1993 Giuseppe Attardi Copyright (C) 2000 Juan J. Garcia-Ripoll ECL is free software, and you are welcome to redistribute it under certain conditions; see file 'Copyright' for details. Type :h for Help. Top level. ... """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%lisp magics instead.') os.system('ecl')
def fricas_console(): """ Spawn a new FriCAS command-line session. EXAMPLES:: sage: fricas_console() #not tested FriCAS (AXIOM fork) Computer Algebra System Version: FriCAS 1.0.5 Timestamp: Thursday February 19, 2009 at 06:57:33 ----------------------------------------------------------------------------- Issue )copyright to view copyright notices. Issue )summary for a summary of useful system commands. Issue )quit to leave AXIOM and return to shell. ----------------------------------------------------------------------------- """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%fricas magics instead.') os.system('fricas -nox')
def axiom_console(): """ Spawn a new Axiom command-line session. EXAMPLES:: sage: axiom_console() #not tested AXIOM Computer Algebra System Version: Axiom (January 2009) Timestamp: Sunday January 25, 2009 at 07:08:54 ----------------------------------------------------------------------------- Issue )copyright to view copyright notices. Issue )summary for a summary of useful system commands. Issue )quit to leave AXIOM and return to shell. ----------------------------------------------------------------------------- """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%axiom magics instead.') os.system('axiom -nox')
def axiom_console(): """ Spawn a new Axiom command-line session. EXAMPLES:: sage: axiom_console() #not tested AXIOM Computer Algebra System Version: Axiom (January 2009) Timestamp: Sunday January 25, 2009 at 07:08:54 ----------------------------------------------------------------------------- Issue )copyright to view copyright notices. Issue )summary for a summary of useful system commands. Issue )quit to leave AXIOM and return to shell. ----------------------------------------------------------------------------- """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%axiom magics instead.') os.system('axiom -nox')
def mupad_console(): """ Spawn a new MuPAD command-line session. EXAMPLES:: sage: from sage.interfaces.mupad import mupad_console sage: mupad_console() #not tested *----* MuPAD Pro 4.0.2 -- The Open Computer Algebra System /| /| *----* | Copyright (c) 1997 - 2007 by SciFace Software | *--|-* All rights reserved. |/ |/ *----* Licensed to: ... """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%mupad magics instead.') os.system('mupkern')
def mupad_console(): """ Spawn a new MuPAD command-line session. EXAMPLES:: sage: from sage.interfaces.mupad import mupad_console sage: mupad_console() #not tested *----* MuPAD Pro 4.0.2 -- The Open Computer Algebra System /| /| *----* | Copyright (c) 1997 - 2007 by SciFace Software | *--|-* All rights reserved. |/ |/ *----* Licensed to: ... """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%mupad magics instead.') os.system('mupkern')
def fricas_console(): """ Spawn a new FriCAS command-line session. EXAMPLES:: sage: fricas_console() #not tested FriCAS (AXIOM fork) Computer Algebra System Version: FriCAS 1.0.5 Timestamp: Thursday February 19, 2009 at 06:57:33 ----------------------------------------------------------------------------- Issue )copyright to view copyright notices. Issue )summary for a summary of useful system commands. Issue )quit to leave AXIOM and return to shell. ----------------------------------------------------------------------------- """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError( 'Can use the console only in the terminal. Try %%fricas magics instead.' ) os.system('fricas -nox')
def gap3_console(): r""" Spawn a new GAP3 command-line session. EXAMPLES:: sage: gap3.console() #not tested ######## Lehrstuhl D fuer Mathematik ### #### RWTH Aachen ## ## ## # ####### ######### ## # ## ## # ## ## # # ## # ## #### ## ## # # ## ##### ### ## ## ## ## ######### # ######### ####### # # ## Version 3 # ### Release 4.4 # ## # 18 Apr 97 # ## # ## # Alice Niemeyer, Werner Nickel, Martin Schoenert ## # Johannes Meier, Alex Wegner, Thomas Bischops ## # Frank Celler, Juergen Mnich, Udo Polis ### ## Thomas Breuer, Goetz Pfeiffer, Hans U. Besche ###### Volkmar Felsch, Heiko Theissen, Alexander Hulpke Ansgar Kaup, Akos Seress, Erzsebet Horvath Bettina Eick For help enter: ?<return> gap> """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError( 'Can use the console only in the terminal. Try %%gap3 magics instead.' ) os.system(gap3_cmd)
def gap3_console(): r""" Spawn a new GAP3 command-line session. EXAMPLES:: sage: gap3.console() #not tested ######## Lehrstuhl D fuer Mathematik ### #### RWTH Aachen ## ## ## # ####### ######### ## # ## ## # ## ## # # ## # ## #### ## ## # # ## ##### ### ## ## ## ## ######### # ######### ####### # # ## Version 3 # ### Release 4.4 # ## # 18 Apr 97 # ## # ## # Alice Niemeyer, Werner Nickel, Martin Schoenert ## # Johannes Meier, Alex Wegner, Thomas Bischops ## # Frank Celler, Juergen Mnich, Udo Polis ### ## Thomas Breuer, Goetz Pfeiffer, Hans U. Besche ###### Volkmar Felsch, Heiko Theissen, Alexander Hulpke Ansgar Kaup, Akos Seress, Erzsebet Horvath Bettina Eick For help enter: ?<return> gap> """ from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%gap3 magics instead.') os.system(gap3_cmd)
def __init__(self, *args, **kwds): """ This is where the Sage rich objects are translated to IPython INPUT/OUTPUT: See the IPython documentation. EXAMPLES: This is part of how Sage works with the IPython output system. It cannot be used in doctests:: sage: from sage.repl.display.formatter import SageDisplayFormatter sage: fmt = SageDisplayFormatter() Traceback (most recent call last): ... RuntimeError: check failed: current backend is invalid """ super(SageDisplayFormatter, self).__init__(*args, **kwds) from sage.repl.rich_output.display_manager import get_display_manager self.dm = get_display_manager() from sage.repl.rich_output.backend_ipython import BackendIPython self.dm.check_backend_class(BackendIPython)
from .tachyon import tachyon_rt from .psage import PSage from .ecm import ECM, ecm from .povray import povray from .lie import lie, LiE from .r import r, R, r_version from .read_data import read_data interfaces = ['gap', 'gap3', 'giac', 'gp', 'mathematica', 'gnuplot', \ 'kash', 'magma', 'macaulay2', 'maple', 'maxima', \ 'mathematica', 'mwrank', 'octave', 'r', \ 'singular', 'sage0', 'sage'] from sage.repl.rich_output.display_manager import get_display_manager if get_display_manager().is_in_terminal(): from .axiom import axiom_console from .fricas import fricas_console from .gap import gap_console from .gap3 import gap3_console from .giac import giac_console from .gp import gp_console from .gnuplot import gnuplot_console from .kash import kash_console from .lisp import lisp_console from .magma import magma_console from .macaulay2 import macaulay2_console from .maple import maple_console from .maxima_abstract import maxima_console from .mathematica import mathematica_console from .matlab import matlab_console
def kash_console(): from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%kash magics instead.') os.system("kash3 ")
from .scilab import scilab from .tachyon import tachyon_rt from .psage import PSage from .ecm import ECM, ecm from .povray import povray from .lie import lie, LiE from .r import r, R, r_version from .read_data import read_data interfaces = ['gap', 'gap3', 'giac', 'gp', 'mathematica', 'gnuplot', \ 'kash', 'magma', 'macaulay2', 'maple', 'maxima', \ 'mathematica', 'mwrank', 'octave', 'r', \ 'singular', 'sage0', 'sage'] from sage.repl.rich_output.display_manager import get_display_manager if get_display_manager().is_in_terminal(): from .axiom import axiom_console from .fricas import fricas_console from .gap import gap_console from .gap3 import gap3_console from .giac import giac_console from .gp import gp_console from .gnuplot import gnuplot_console from .kash import kash_console from .lisp import lisp_console from .magma import magma_console from .macaulay2 import macaulay2_console from .maple import maple_console from .maxima_abstract import maxima_console from .mathematica import mathematica_console from .matlab import matlab_console
def gnuplot_console(): from sage.repl.rich_output.display_manager import get_display_manager if not get_display_manager().is_in_terminal(): raise RuntimeError('Can use the console only in the terminal. Try %%gnuplot magics instead.') os.system('sage-native-execute gnuplot')