コード例 #1
0
    def __init__(self,
                 maxread=None,
                 script_subdirectory=None,
                 logfile=None,
                 server=None,
                 server_tmpdir=None,
                 seed=None):
        """
        Initializes the Scilab class.

        EXAMPLES::

            sage: from sage.interfaces.scilab import Scilab
            sage: sci_obj = Scilab()
            sage: del sci_obj
        """
        Expect.__init__(self,
                        name='scilab',
                        prompt='-->',
                        command="scilab -nw",
                        server=server,
                        server_tmpdir=server_tmpdir,
                        script_subdirectory=script_subdirectory,
                        restart_on_ctrlc=False,
                        verbose_start=False,
                        logfile=logfile,
                        eval_using_file_cutoff=100)
        self._seed = seed
コード例 #2
0
    def __init__(self,
                 maxread=100,
                 script_subdirectory="",
                 logfile=None,
                 server=None,
                 server_tmpdir=None):
        """
        EXAMPLES::

            sage: octave == loads(dumps(octave))
            True
        """
        Expect.__init__(
            self,
            name='octave',
            prompt='>',
            command="sage-native-execute octave --no-line-editing --silent",
            maxread=maxread,
            server=server,
            server_tmpdir=server_tmpdir,
            script_subdirectory=script_subdirectory,
            restart_on_ctrlc=False,
            verbose_start=False,
            logfile=logfile,
            eval_using_file_cutoff=100)
コード例 #3
0
ファイル: axiom.py プロジェクト: bopopescu/spd_notebook
 def __init__(self,
              script_subdirectory=None,
              logfile=None,
              server=None,
              server_tmpdir=None):
     """
     Create an instance of the Axiom interpreter.
     
     TESTS::
     
         sage: axiom == loads(dumps(axiom))
         True
     """
     eval_using_file_cutoff = 200
     self.__eval_using_file_cutoff = eval_using_file_cutoff
     Expect.__init__(
         self,
         name='axiom',
         prompt='\([0-9]+\) -> ',
         command="axiom -nox -noclef",
         maxread=10,
         script_subdirectory=script_subdirectory,
         server=server,
         server_tmpdir=server_tmpdir,
         restart_on_ctrlc=False,
         verbose_start=False,
         #init_code = [')lisp (si::readline-off)'],
         logfile=logfile,
         eval_using_file_cutoff=eval_using_file_cutoff)
コード例 #4
0
ファイル: scilab.py プロジェクト: Findstat/sage
    def __init__(self, maxread=100, script_subdirectory=None,
                 logfile=None, server=None,server_tmpdir=None,
                 seed=None):
        """
        Initializes the Scilab class.

        EXAMPLES::

            sage: from sage.interfaces.scilab import Scilab
            sage: sci_obj = Scilab()
            sage: del sci_obj
        """
        Expect.__init__(self,
                        name = 'scilab',
                        prompt = '-->',
                        command = "scilab -nw",
                        maxread = maxread,
                        server = server,
                        server_tmpdir = server_tmpdir,
                        script_subdirectory = script_subdirectory,
                        restart_on_ctrlc = False,
                        verbose_start = False,
                        logfile = logfile,
                        eval_using_file_cutoff=100)
        self._seed = seed
コード例 #5
0
 def __init__(
         self,
         stacksize=10000000,  # 10MB
         maxread=100000,
         script_subdirectory=None,
         logfile=None,
         server=None,
         server_tmpdir=None,
         init_list_length=1024):
     """
     EXAMPLES::
     
         sage: gp == loads(dumps(gp))
         True
     """
     Expect.__init__(self,
                     name='pari',
                     prompt='\\? ',
                     command="gp --emacs --fast --quiet --stacksize %s" %
                     stacksize,
                     maxread=maxread,
                     server=server,
                     server_tmpdir=server_tmpdir,
                     script_subdirectory=script_subdirectory,
                     restart_on_ctrlc=False,
                     verbose_start=False,
                     logfile=logfile,
                     eval_using_file_cutoff=50)
     self.__seq = 0
     self.__var_store_len = 0
     self.__init_list_length = init_list_length
コード例 #6
0
ファイル: mupad.py プロジェクト: sagemathinc/smc-sage
    def __init__(self,
                 maxread=1000,
                 script_subdirectory=None,
                 server=None,
                 server_tmpdir=None,
                 logfile=None):
        """
        Create an instance of the MuPAD interpreter.

        EXAMPLES::

            sage: mupad == loads(dumps(mupad))                      # optional - mupad
            True
        """
        Expect.__init__(
            self,
            name='MuPAD',
            prompt=PROMPT,
            # the -U SAGE=TRUE allows for MuPAD programs to test whether they are run from Sage
            command="mupkern -P e -U SAGE=TRUE",
            maxread=maxread,
            script_subdirectory=script_subdirectory,
            server=server,
            server_tmpdir=server_tmpdir,
            restart_on_ctrlc=False,
            verbose_start=False,
            logfile=None)
コード例 #7
0
 def __init__(self,
              maxread=100,
              script_subdirectory="",
              server=None,
              server_tmpdir=None,
              logfile=None):
     """
     Create an instance of the Maple interpreter.
     
     EXAMPLES::
     
         sage: maple == loads(dumps(maple))
         True
     """
     Expect.__init__(
         self,
         name='maple',
         prompt='#-->',
         command="maple -t",
         maxread=maxread,
         script_subdirectory=script_subdirectory,
         restart_on_ctrlc=False,
         server=server,
         server_tmpdir=server_tmpdir,
         verbose_start=False,
         logfile=logfile,
         eval_using_file_cutoff=1)  # very important that this is 1
コード例 #8
0
ファイル: kash.py プロジェクト: manguluka/sage
    def __init__(self,
                 max_workspace_size=None,
                 maxread=None,
                 script_subdirectory=None,
                 restart_on_ctrlc=True,
                 logfile=None,
                 server=None,
                 server_tmpdir=None):
        """
        INPUT:
            max_workspace_size -- (default: None)
                    set maximal workspace memory usage to <mem>
                    <mem> stands for byte-wise allocation
                    <mem>k stands for kilobyte-wise allocation
                    <mem>m stands for megabyte-wise allocation
        """

        cmd = "kash3 -b -c -d  "
        if max_workspace_size is not None:
            cmd += " -a %s" % int(max_workspace_size)
        Expect.__init__(self,
                        name='kash',
                        prompt='kash% ',
                        command=cmd,
                        server=server,
                        server_tmpdir=server_tmpdir,
                        script_subdirectory=script_subdirectory,
                        restart_on_ctrlc=True,
                        verbose_start=False,
                        logfile=logfile,
                        eval_using_file_cutoff=100,
                        init_code=['X:=ZX.1;'])
        # The above init_code programs around a bug reported by Jack Schmidt

        self.__seq = 0
コード例 #9
0
ファイル: gp.py プロジェクト: pombredanne/spd_notebook
 def __init__(self, stacksize=10000000,   # 10MB
              maxread=100000, script_subdirectory=None,
              logfile=None,
              server=None,
              server_tmpdir=None,
              init_list_length=1024):
     """
     EXAMPLES::
     
         sage: gp == loads(dumps(gp))
         True
     """
     Expect.__init__(self,
                     name = 'pari',
                     prompt = '\\? ',
                     command = "gp --emacs --fast --quiet --stacksize %s"%stacksize,
                     maxread = maxread,
                     server=server,
                     server_tmpdir=server_tmpdir,
                     script_subdirectory = script_subdirectory,
                     restart_on_ctrlc = False,
                     verbose_start = False,
                     logfile=logfile,
                     eval_using_file_cutoff=50)
     self.__seq = 0
     self.__var_store_len = 0
     self.__init_list_length = init_list_length
コード例 #10
0
ファイル: axiom.py プロジェクト: bopopescu/sagelib-1
 def __init__(self,
              name='axiom',
              command='axiom -nox -noclef',
              script_subdirectory=None,
              logfile=None,
              server=None,
              server_tmpdir=None,
              init_code=[')lisp (si::readline-off)']):
     """
     Create an instance of the Axiom interpreter.
     
     TESTS::
     
         sage: axiom == loads(dumps(axiom))
         True
     """
     eval_using_file_cutoff = 200
     self.__eval_using_file_cutoff = eval_using_file_cutoff
     self._COMMANDS_CACHE = '%s/%s_commandlist_cache.sobj' % (DOT_SAGE,
                                                              name)
     Expect.__init__(self,
                     name=name,
                     prompt='\([0-9]+\) -> ',
                     command=command,
                     maxread=10,
                     script_subdirectory=script_subdirectory,
                     server=server,
                     server_tmpdir=server_tmpdir,
                     restart_on_ctrlc=False,
                     verbose_start=False,
                     init_code=init_code,
                     logfile=logfile,
                     eval_using_file_cutoff=eval_using_file_cutoff)
     self._prompt_wait = self._prompt
コード例 #11
0
ファイル: maple.py プロジェクト: aaditya-thakkar/sage
    def __init__(self, maxread=None, script_subdirectory=None, server=None,
            server_tmpdir=None, logfile=None, ulimit=None):
        """
        Create an instance of the Maple interpreter.

        EXAMPLES::

            sage: maple == loads(dumps(maple))
            True
        """
        __maple_iface_opts = [
            'screenwidth=infinity',
            'errorcursor=false',]
        __maple_command = 'maple -t -c "interface({})"'.format(
            ','.join(__maple_iface_opts))
        #errorcursor=false avoids maple command line interface to dump
        #into the editor when an error occurs. Thus pexpect interface
        #is not messed up if a maple error occurs.
        #screenwidth=infinity prevents maple command interface from cutting 
        #your input lines. By doing this, file interface also works in the
        #event that  sage_user_home + sage_tmp_file_stuff exceeds the 
        #length of 79 characters.
        Expect.__init__(self,
                        name = 'maple',
                        prompt = '#-->',
                        command = __maple_command,
                        server = server,
                        server_tmpdir = server_tmpdir,
                        ulimit = ulimit,
                        script_subdirectory = script_subdirectory,
                        restart_on_ctrlc = False,
                        verbose_start = False,
                        logfile = logfile,
                        eval_using_file_cutoff=2048)  # 2048 is
コード例 #12
0
ファイル: axiom.py プロジェクト: williamstein/sagelib
 def __init__(self, name='axiom', command='axiom -nox -noclef',
              script_subdirectory=None, logfile=None,
              server=None, server_tmpdir=None,
              init_code=[')lisp (si::readline-off)']):
     """
     Create an instance of the Axiom interpreter.
     
     TESTS::
     
         sage: axiom == loads(dumps(axiom))
         True
     """
     eval_using_file_cutoff = 200
     self.__eval_using_file_cutoff = eval_using_file_cutoff
     self._COMMANDS_CACHE = '%s/%s_commandlist_cache.sobj'%(DOT_SAGE, name)
     Expect.__init__(self,
                     name = name,
                     prompt = '\([0-9]+\) -> ',
                     command = command,
                     maxread = 10, 
                     script_subdirectory = script_subdirectory,
                     server=server,
                     server_tmpdir=server_tmpdir,
                     restart_on_ctrlc = False,
                     verbose_start = False,
                     init_code = init_code,
                     logfile = logfile,
                     eval_using_file_cutoff=eval_using_file_cutoff)
     self._prompt_wait = self._prompt
コード例 #13
0
 def __init__(self, server=None, server_tmpdir=None, logfile=None):
     Expect.__init__(self,
                     name='genus2reduction',
                     prompt='enter',
                     command='genus2reduction',
                     server=server,
                     server_tmpdir=server_tmpdir,
                     maxread=10000,
                     restart_on_ctrlc=True,
                     logfile=logfile,
                     verbose_start=False)
コード例 #14
0
ファイル: genus2reduction.py プロジェクト: Etn40ff/sage
 def __init__(self, server=None, server_tmpdir=None, logfile=None):
     Expect.__init__(self,
                     name = 'genus2reduction',
                     prompt = 'enter',
                     command = 'genus2reduction',
                     server = server,
                     server_tmpdir = server_tmpdir,
                     maxread = 10000,
                     restart_on_ctrlc = True,
                     logfile = logfile,
                     verbose_start = False)
コード例 #15
0
ファイル: mathematica.py プロジェクト: CETHop/sage
 def __init__(self, maxread=100, script_subdirectory="", logfile=None, server=None, server_tmpdir=None):
     Expect.__init__(self,
                     name = 'mathematica',
                     prompt = 'In[[0-9]+]:=',
                     command = "math",
                     maxread = maxread,
                     server = server,
                     server_tmpdir = server_tmpdir,
                     script_subdirectory = script_subdirectory,
                     verbose_start = False,
                     logfile=logfile,
                     eval_using_file_cutoff=50)
コード例 #16
0
ファイル: matlab.py プロジェクト: manguluka/sage
 def __init__(self, maxread=None, script_subdirectory=None,
              logfile=None, server=None,server_tmpdir=None):
     Expect.__init__(self,
                     name = 'matlab',
                     prompt = '>> ',
                     command = "sage-native-execute matlab -nodisplay",
                     server = server,
                     server_tmpdir = server_tmpdir,
                     script_subdirectory = script_subdirectory,
                     restart_on_ctrlc = False,
                     verbose_start = False,
                     logfile = logfile,
                     eval_using_file_cutoff=100)
コード例 #17
0
ファイル: mwrank.py プロジェクト: Findstat/sage
    def __init__(self, options="", server=None,server_tmpdir=None):
        """
        INPUT:


        -  ``options`` - string; passed when starting mwrank.
           The format is::

           -h       help            prints this info and quits
           -q       quiet           turns OFF banner display and prompt
           -v n     verbosity       sets verbosity to n (default=1)
           -o       PARI/GP output  turns ON extra PARI/GP short output (default is OFF)
           -p n     precision       sets precision to n decimals (default=15)
           -b n     quartic bound   bound on quartic point search (default=10)
           -x n     n aux           number of aux primes used for sieving (default=6)
           -l       list            turns ON listing of points (default ON unless v=0)
           -s       selmer_only     if set, computes Selmer rank only (default: not set)
           -d       skip_2nd_descent        if set, skips the second descent for curves with 2-torsion (default: not set)
           -S n     sat_bd          upper bound on saturation primes (default=100, -1 for automatic)

    .. warning:

       Do not use the option "-q" which turns off the prompt.


        .. note::

           Normally instances of this class would be created by
           calling the global function :meth:`Mwrank`.

        EXAMPLES::

            sage: from sage.interfaces.mwrank import Mwrank_class
            sage: M = Mwrank_class('-v 0 -l')
            sage: M('0 -1 1 0 0')
            'Curve [0,-1,1,0,0] :...Rank = 0...Regulator = 1...'

            sage: from sage.interfaces.mwrank import Mwrank_class
            sage: TestSuite(Mwrank_class).run()
        """
        Expect.__init__(self,
                        name = 'mwrank',
                        prompt = 'Enter curve: ',
                        command = "mwrank %s"%options,
                        server = server,
                        server_tmpdir = server_tmpdir,
                        maxread = 10000,
                        restart_on_ctrlc = True,
                        verbose_start = False)
コード例 #18
0
    def __init__(self, options="", server=None, server_tmpdir=None):
        """
        INPUT:


        -  ``options`` - string; passed when starting mwrank.
           The format is::

           -h       help            prints this info and quits
           -q       quiet           turns OFF banner display and prompt
           -v n     verbosity       sets verbosity to n (default=1)
           -o       PARI/GP output  turns ON extra PARI/GP short output (default is OFF)
           -p n     precision       sets precision to n decimals (default=15)
           -b n     quartic bound   bound on quartic point search (default=10)
           -x n     n aux           number of aux primes used for sieving (default=6)
           -l       list            turns ON listing of points (default ON unless v=0)
           -s       selmer_only     if set, computes Selmer rank only (default: not set)
           -d       skip_2nd_descent        if set, skips the second descent for curves with 2-torsion (default: not set)
           -S n     sat_bd          upper bound on saturation primes (default=100, -1 for automatic)

    .. warning:

       Do not use the option "-q" which turns off the prompt.


        .. note::

           Normally instances of this class would be created by
           calling the global function :meth:`Mwrank`.

        EXAMPLES::

            sage: from sage.interfaces.mwrank import Mwrank_class
            sage: M = Mwrank_class('-v 0 -l')
            sage: M('0 -1 1 0 0')
            'Curve [0,-1,1,0,0] :...Rank = 0...Regulator = 1...'

            sage: from sage.interfaces.mwrank import Mwrank_class
            sage: TestSuite(Mwrank_class).run()
        """
        Expect.__init__(self,
                        name='mwrank',
                        prompt='Enter curve: ',
                        command="mwrank %s" % options,
                        server=server,
                        server_tmpdir=server_tmpdir,
                        maxread=10000,
                        restart_on_ctrlc=True,
                        verbose_start=False)
コード例 #19
0
ファイル: macaulay2.py プロジェクト: sagemathinc/smc-sage
    def __init__(self,
                 maxread=10000,
                 script_subdirectory=None,
                 logfile=None,
                 server=None,
                 server_tmpdir=None):
        """
        Initialize a Macaulay2 interface instance.

        We replace the standard input prompt with a strange one, so that
        we do not catch input prompts inside the documentation.

        We replace the standard input continuation prompt, which is
        just a bunch of spaces and cannot be automatically detected in a
        reliable way. This is necessary for allowing commands that occupy
        several strings.

        We also change the starting line number to make all the output
        labels to be of the same length. This allows correct stripping of
        the output of several commands.

        TESTS::

            sage: macaulay2 == loads(dumps(macaulay2))
            True
        """
        init_str = (
            # Prompt changing commands
            """ZZ#{Standard,Core#"private dictionary"#"InputPrompt"} = lineno -> "%s";"""
            % PROMPT +
            """ZZ#{Standard,Core#"private dictionary"#"InputContinuationPrompt"} = lineno -> "%s";"""
            % PROMPT +
            # Also prevent line wrapping in Macaulay2
            "printWidth = 0;" +
            # And make all output labels to be of the same width
            "lineNumber = 10^9;")
        Expect.__init__(
            self,
            name='macaulay2',
            prompt=PROMPT,
            command="M2 --no-debug --no-readline --silent -e '%s'" % init_str,
            maxread=maxread,
            server=server,
            server_tmpdir=server_tmpdir,
            script_subdirectory=script_subdirectory,
            verbose_start=False,
            logfile=logfile,
            eval_using_file_cutoff=500)
コード例 #20
0
ファイル: lie.py プロジェクト: matsen/sage
    def __init__(self,
                 maxread=100000,
                 script_subdirectory=None,
                 logfile=None,
                 server=None):
        """
        EXAMPLES::

            sage: lie == loads(dumps(lie))
            True
        """
        Expect.__init__(
            self,

            # The capitalized version of this is used for printing.
            name='LiE',

            # This is regexp of the input prompt.  If you can change
            # it to be very obfuscated that would be better.   Even
            # better is to use sequence numbers.
            prompt='> ',

            # This is the command that starts up your program
            command="bash " + SAGE_LOCAL + "/bin/lie",
            maxread=maxread,
            server=server,
            script_subdirectory=script_subdirectory,

            # If this is true, then whenever the user presses Control-C to
            # interrupt a calculation, the whole interface is restarted.
            restart_on_ctrlc=False,

            # If true, print out a message when starting
            # up the command when you first send a command
            # to this interface.
            verbose_start=False,
            logfile=logfile,

            # If an input is longer than this number of characters, then
            # try to switch to outputting to a file.
            eval_using_file_cutoff=1024)

        self._seq = 0

        self._trait_names_dict = None
        self._trait_names_list = None
        self._help_dict = None
コード例 #21
0
ファイル: gp.py プロジェクト: manguluka/sage
    def __init__(
            self,
            stacksize=10000000,  # 10MB
            maxread=None,
            script_subdirectory=None,
            logfile=None,
            server=None,
            server_tmpdir=None,
            init_list_length=1024,
            seed=None):
        """
        Initialization of this PARI gp interpreter.

        INPUT:

        - ``stacksize`` (int, default 10000000) -- the initial PARI
          stacksize in bytes (default 10MB)
        - ``script_subdirectory`` (string, default None) -- name of the subdirectory of SAGE_EXTCODE/pari from which to read scripts
        - ``logfile`` (string, default None) -- log file for the pexpect interface
        - ``server`` -- name of remote server
        - ``server_tmpdir`` -- name of temporary directory on remote server
        - ``init_list_length`` (int, default 1024) -- length of initial list of local variables.
        - ``seed`` (int,default random nonzero 31 bit integer) -- value of random seed

        EXAMPLES::

            sage: gp == loads(dumps(gp))
            True
        """
        Expect.__init__(
            self,
            name='pari',
            prompt='\\? ',
            # --fast so the system gprc isn't read (we configure below)
            command="gp --fast --emacs --quiet --stacksize %s" % stacksize,
            maxread=maxread,
            server=server,
            server_tmpdir=server_tmpdir,
            script_subdirectory=script_subdirectory,
            restart_on_ctrlc=False,
            verbose_start=False,
            logfile=logfile,
            eval_using_file_cutoff=1024)
        self.__seq = 0
        self.__var_store_len = 0
        self.__init_list_length = init_list_length
        self._seed = seed
コード例 #22
0
ファイル: lie.py プロジェクト: BlairArchibald/sage
    def __init__(self,
                 maxread=100000, script_subdirectory=None,
                 logfile=None,
                 server=None):
        """
        EXAMPLES::

            sage: lie == loads(dumps(lie))
            True
        """
        Expect.__init__(self,

                        # The capitalized version of this is used for printing.
                        name = 'LiE',

                        # This is regexp of the input prompt.  If you can change
                        # it to be very obfuscated that would be better.   Even
                        # better is to use sequence numbers.
                        prompt = '> ',

                        # This is the command that starts up your program
                        command = "bash "+ SAGE_LOCAL + "/bin/lie",

                        maxread = maxread,
                        server=server,
                        script_subdirectory = script_subdirectory,

                        # If this is true, then whenever the user presses Control-C to
                        # interrupt a calculation, the whole interface is restarted.
                        restart_on_ctrlc = False,

                        # If true, print out a message when starting
                        # up the command when you first send a command
                        # to this interface.
                        verbose_start = False,

                        logfile=logfile,

                        # If an input is longer than this number of characters, then
                        # try to switch to outputting to a file.
                        eval_using_file_cutoff=1024)

        self._seq = 0

        self._trait_names_dict = None
        self._trait_names_list = None
        self._help_dict = None
コード例 #23
0
ファイル: gp.py プロジェクト: nvcleemp/sage
    def __init__(
        self,
        stacksize=10000000,  # 10MB
        maxread=100000,
        script_subdirectory=None,
        logfile=None,
        server=None,
        server_tmpdir=None,
        init_list_length=1024,
    ):
        """
        Initialization of this PARI gp interpreter.

        INPUT:

        - ``stacksize`` (int, default 10000000) -- the initial PARI
          stacksize in bytes (default 10MB)
        - ``maxread`` (int, default 100000) -- ??
        - ``script_subdirectory`` (string, default None) -- name of the subdirectory of SAGE_EXTCODE/pari from which to read scripts
        - ``logfile`` (string, default None) -- log file for the pexpect interface
        - ``server`` -- name of remote server
        - ``server_tmpdir`` -- name of temporary directory on remote server
        - ``init_list_length`` (int, default 1024) -- length of initial list of local variables.

        EXAMPLES::

            sage: gp == loads(dumps(gp))
            True
        """
        Expect.__init__(
            self,
            name="pari",
            prompt="\\? ",
            command="gp --emacs --quiet --stacksize %s" % stacksize,
            maxread=maxread,
            server=server,
            server_tmpdir=server_tmpdir,
            script_subdirectory=script_subdirectory,
            restart_on_ctrlc=False,
            verbose_start=False,
            logfile=logfile,
            eval_using_file_cutoff=1024,
        )
        self.__seq = 0
        self.__var_store_len = 0
        self.__init_list_length = init_list_length
コード例 #24
0
 def __init__(self,
              maxread=100,
              script_subdirectory="",
              logfile=None,
              server=None,
              server_tmpdir=None):
     Expect.__init__(self,
                     name='mathematica',
                     prompt='In[[0-9]+]:=',
                     command="math",
                     maxread=maxread,
                     server=server,
                     server_tmpdir=server_tmpdir,
                     script_subdirectory=script_subdirectory,
                     verbose_start=False,
                     logfile=logfile,
                     eval_using_file_cutoff=50)
コード例 #25
0
ファイル: sage0.py プロジェクト: regmi/femhub_notebook
 def __init__(self, logfile   = None,
                    preparse  = True,
                    python    = False,
                    init_code = None,
                    server    = None,
                    server_tmpdir = None,
                    remote_cleaner = True,
                    **kwds):
     """
     EXAMPLES::
     
         sage: sage0 == loads(dumps(sage0))
         True
     """
     from sage.misc.misc import SAGE_ROOT
     if python:
         if server:
             command = "femhub -python -u"
         else:
             command = SAGE_ROOT + "/femhub -python -u"
         prompt = ">>>"
         if init_code is None:
             init_code = ['from sage.all import *', 'import cPickle']
     else:
         if server:
             command = "femhub"
         else:
             command = SAGE_ROOT + "/femhub"
         prompt = "sage: "
         if init_code is None:
             init_code = ['import cPickle', '%colors NoColor']
     
     Expect.__init__(self,
                     name = 'sage',
                     prompt = prompt,
                     command = command,
                     restart_on_ctrlc = False,
                     logfile = logfile,
                     init_code = init_code,
                     server = server,
                     server_tmpdir = server_tmpdir,
                     remote_cleaner = remote_cleaner,
                     **kwds
                     )
     self._preparse = preparse
コード例 #26
0
ファイル: macaulay2.py プロジェクト: regmi/femhub_notebook
 def __init__(self, maxread=10000, script_subdirectory="",
              logfile=None, server=None,server_tmpdir=None):
     """
     TESTS:
         sage: macaulay2 == loads(dumps(macaulay2))
         True
     """
     Expect.__init__(self,
                     name = 'macaulay2',
                     prompt = 'i[0-9]* : ',
                     command = "M2 --no-debug --no-readline --silent ",
                     maxread = maxread,
                     server = server, 
                     server_tmpdir = server_tmpdir,
                     script_subdirectory = script_subdirectory,
                     verbose_start = False,
                     logfile = logfile,
                     eval_using_file_cutoff=500)
コード例 #27
0
ファイル: mwrank.py プロジェクト: bopopescu/spd_notebook
 def __init__(self, options="", server=None, server_tmpdir=None):
     """
     INPUT:
     
     
     -  ``options`` - string; passed when starting mwrank.
        The format is q pprecision vverbosity bhlim_q xnaux chlim_c l t o
        s d]
     """
     Expect.__init__(self,
                     name='mwrank',
                     prompt='Enter curve: ',
                     command="mwrank %s" % options,
                     server=server,
                     server_tmpdir=server_tmpdir,
                     maxread=10000,
                     restart_on_ctrlc=True,
                     verbose_start=False)
コード例 #28
0
ファイル: mwrank.py プロジェクト: pombredanne/spd_notebook
 def __init__(self, options="", server=None,server_tmpdir=None):
     """
     INPUT:
     
     
     -  ``options`` - string; passed when starting mwrank.
        The format is q pprecision vverbosity bhlim_q xnaux chlim_c l t o
        s d]
     """
     Expect.__init__(self,
                     name = 'mwrank',
                     prompt = 'Enter curve: ',
                     command = "mwrank %s"%options,
                     server = server,
                     server_tmpdir = server_tmpdir,
                     maxread = 10000,
                     restart_on_ctrlc = True,
                     verbose_start = False)
コード例 #29
0
ファイル: sage0.py プロジェクト: pombredanne/sage-1
    def __init__(
        self,
        logfile=None,
        preparse=True,
        python=False,
        init_code=None,
        server=None,
        server_tmpdir=None,
        remote_cleaner=True,
        **kwds
    ):
        """
        EXAMPLES::
        
            sage: sage0 == loads(dumps(sage0))
            True
        """
        if python:
            command = "python -u"
            prompt = ">>>"
            if init_code is None:
                init_code = ["from sage.all import *", "import cPickle"]
        else:
            # Disable the IPython history (implemented as SQLite database)
            # to avoid problems with locking.
            command = "sage-ipython --HistoryManager.hist_file=:memory: --colors=NoColor"
            prompt = "sage: "
            if init_code is None:
                init_code = ["import cPickle"]

        Expect.__init__(
            self,
            name="sage",
            prompt=prompt,
            command=command,
            restart_on_ctrlc=False,
            logfile=logfile,
            init_code=init_code,
            server=server,
            server_tmpdir=server_tmpdir,
            remote_cleaner=remote_cleaner,
            **kwds
        )
        self._preparse = preparse
コード例 #30
0
ファイル: macaulay2.py プロジェクト: nvcleemp/sage
    def __init__(self, maxread=10000, script_subdirectory="", logfile=None, server=None, server_tmpdir=None):
        """
        Initialize a Macaulay2 interface instance.

        We replace the standard input prompt with a strange one, so that
        we do not catch input prompts inside the documentation.

        We replace the standard input continuation prompt, which is
        just a bunch of spaces and cannot be automatically detected in a
        reliable way. This is necessary for allowing commands that occupy
        several strings.

        We also change the starting line number to make all the output
        labels to be of the same length. This allows correct stripping of
        the output of several commands.

        TESTS:
            sage: macaulay2 == loads(dumps(macaulay2))
            True
        """
        init_str = (
            # Prompt changing commands
            """ZZ#{Standard,Core#"private dictionary"#"InputPrompt"} = lineno -> "%s";""" % PROMPT
            + """ZZ#{Standard,Core#"private dictionary"#"InputContinuationPrompt"} = lineno -> "%s";""" % PROMPT
            +
            # Also prevent line wrapping in Macaulay2
            "printWidth = 0;"
            +
            # And make all output labels to be of the same width
            "lineNumber = 10^9;"
        )
        Expect.__init__(
            self,
            name="macaulay2",
            prompt=PROMPT,
            command="M2 --no-debug --no-readline --silent -e '%s'" % init_str,
            maxread=maxread,
            server=server,
            server_tmpdir=server_tmpdir,
            script_subdirectory=script_subdirectory,
            verbose_start=False,
            logfile=logfile,
            eval_using_file_cutoff=500,
        )
コード例 #31
0
ファイル: nlgf.py プロジェクト: wmacmil/gf-contrib
 def __init__(self, pgf_path, lang, maxread=100, script_subdirectory="", logfile=None,
              server=None, server_tmpdir=None):
     from os.path import splitext, basename
     module_name = splitext(basename(pgf_path))[0]
     Expect.__init__(self,
                     name = 'gf',
                     prompt = module_name + '>',
                     command = "gf -q %s" % pgf_path,
                     maxread = maxread,
                     server = server,
                     server_tmpdir = server_tmpdir,
                     script_subdirectory = script_subdirectory,
                     restart_on_ctrlc = False,
                     verbose_start = DEBUG,
                     logfile = logfile,
                     eval_using_file_cutoff=1024)
     self.lang = lang
     self.locals = None
     self.pgf_path = pgf_path
コード例 #32
0
ファイル: gp.py プロジェクト: robertzk/lmfdb
    def __init__(self, stacksize=10000000,   # 10MB
                 maxread=100000, script_subdirectory=None,
                 logfile=None,
                 server=None,
                 server_tmpdir=None,
                 init_list_length=1024):
        """
        Initialization of this PARI gp interpreter.

        INPUT:

        - ``stacksize`` (int, default 10000000) -- the initial PARI
          stacksize in bytes (default 10MB)
        - ``maxread`` (int, default 100000) -- ??
        - ``script_subdirectory`` (string, default None) -- name of the subdirectory of SAGE_ROOT/data/extcode/pari from which to read scripts
        - ``logfile`` (string, default None) -- log file for the pexpect interface
        - ``server`` -- name of remote server
        - ``server_tmpdir`` -- name of temporary directory on remote server
        - ``init_list_length`` (int, default 1024) -- length of initial list of local variables.

        EXAMPLES::
        
            sage: gp == loads(dumps(gp))
            True
        """
        Expect.__init__(self,
                        name = 'pari',
                        prompt = '\\? ',
                        command = "gp --emacs --fast --quiet --stacksize %s"%stacksize,
                        maxread = maxread,
                        server=server,
                        server_tmpdir=server_tmpdir,
                        script_subdirectory = script_subdirectory,
                        restart_on_ctrlc = False,
                        verbose_start = False,
                        logfile=logfile,
                        eval_using_file_cutoff=50)
        self.__seq = 0
        self.__var_store_len = 1024 # 0
        #print "Hacking __var_store_len"
        self.__init_list_length = init_list_length
        # gp starts up with this set to 1, which makes pexpect hang:
        self.set_default('breakloop',0)
コード例 #33
0
ファイル: octave.py プロジェクト: Etn40ff/sage
    def __init__(self, maxread=100, script_subdirectory="", logfile=None, server=None, server_tmpdir=None):
        """
        EXAMPLES::

            sage: octave == loads(dumps(octave))
            True
        """
        Expect.__init__(self,
                        name = 'octave',
                        prompt = '>',
                        command = "sage-native-execute octave --no-line-editing --silent",
                        maxread = maxread,
                        server = server,
                        server_tmpdir = server_tmpdir,
                        script_subdirectory = script_subdirectory,
                        restart_on_ctrlc = False,
                        verbose_start = False,
                        logfile = logfile,
                        eval_using_file_cutoff=100)
コード例 #34
0
ファイル: gp.py プロジェクト: anuragwaliya/sage
    def __init__(self, stacksize=10000000,   # 10MB
                 maxread=None, script_subdirectory=None,
                 logfile=None,
                 server=None,
                 server_tmpdir=None,
                 init_list_length=1024,
                 seed=None):
        """
        Initialization of this PARI gp interpreter.

        INPUT:

        - ``stacksize`` (int, default 10000000) -- the initial PARI
          stacksize in bytes (default 10MB)
        - ``script_subdirectory`` (string, default None) -- name of the subdirectory of SAGE_EXTCODE/pari from which to read scripts
        - ``logfile`` (string, default None) -- log file for the pexpect interface
        - ``server`` -- name of remote server
        - ``server_tmpdir`` -- name of temporary directory on remote server
        - ``init_list_length`` (int, default 1024) -- length of initial list of local variables.
        - ``seed`` (int,default random nonzero 31 bit integer) -- value of random seed

        EXAMPLES::

            sage: gp == loads(dumps(gp))
            True
        """
        Expect.__init__(self,
                        name = 'pari',
                        prompt = '\\? ',
                        # --fast so the system gprc isn't read (we configure below)
                        command = "gp --fast --emacs --quiet --stacksize %s"%stacksize,
                        maxread = maxread,
                        server=server,
                        server_tmpdir=server_tmpdir,
                        script_subdirectory = script_subdirectory,
                        restart_on_ctrlc = False,
                        verbose_start = False,
                        logfile=logfile,
                        eval_using_file_cutoff=1024)
        self.__seq = 0
        self.__var_store_len = 0
        self.__init_list_length = init_list_length
        self._seed = seed
コード例 #35
0
ファイル: gap.py プロジェクト: bopopescu/spd_notebook
 def __init__(self,
              max_workspace_size=None,
              maxread=100000,
              script_subdirectory=None,
              use_workspace_cache=True,
              server=None,
              server_tmpdir=None,
              logfile=None):
     """
     EXAMPLES::
     
         sage: gap == loads(dumps(gap))
         True
     """
     if os.uname()[-1] == 'ia64':
         # workspace cache is buggy on Itanium in GAP-4.4.12 -- see #5455.
         use_workspace_cache = False
     self.__use_workspace_cache = use_workspace_cache
     cmd, self.__make_workspace = gap_command(use_workspace_cache,
                                              server is None)
     cmd += " -b -p -T"
     if max_workspace_size != None:
         cmd += " -o %s" % int(max_workspace_size)
     else:  # unlimited
         if is_64_bit:
             cmd += " -o 9999G"
         else:
             cmd += " -o 3900m"
     cmd += " %s/extcode/gap/sage.g" % DB_HOME
     Expect.__init__(self,
                     name='gap',
                     prompt='gap> ',
                     command=cmd,
                     maxread=maxread,
                     server=server,
                     server_tmpdir=server_tmpdir,
                     script_subdirectory=script_subdirectory,
                     restart_on_ctrlc=True,
                     verbose_start=False,
                     logfile=logfile,
                     eval_using_file_cutoff=100)
     self.__seq = 0
コード例 #36
0
ファイル: mupad.py プロジェクト: bukzor/sage
    def __init__(self, maxread=1000, script_subdirectory=None, server=None, server_tmpdir=None, logfile=None):
        """
        Create an instance of the MuPAD interpreter.

        EXAMPLES:
            sage: mupad == loads(dumps(mupad))                      # optional - mupad
            True
        """
        Expect.__init__(self,
                        name = 'MuPAD',
                        prompt = PROMPT,
                        # the -U SAGE=TRUE allows for MuPAD programs to test whether they are run from Sage
                        command = "mupkern -P e -U SAGE=TRUE",
                        maxread = maxread,
                        script_subdirectory = script_subdirectory,
                        server = server,
                        server_tmpdir = server_tmpdir,
                        restart_on_ctrlc = False,
                        verbose_start = False,
                        logfile = None)
コード例 #37
0
ファイル: sage0.py プロジェクト: thalespaiva/sagelib
    def __init__(self,
                 logfile=None,
                 preparse=True,
                 python=False,
                 init_code=None,
                 server=None,
                 server_tmpdir=None,
                 remote_cleaner=True,
                 **kwds):
        """
        EXAMPLES::
        
            sage: sage0 == loads(dumps(sage0))
            True
        """
        if python:
            if server:
                command = "sage -python -u"
            else:
                command = "sage -python -u"
            prompt = ">>>"
            if init_code is None:
                init_code = ['from sage.all import *', 'import cPickle']
        else:
            command = "sage"
            prompt = "sage: "
            if init_code is None:
                init_code = ['import cPickle', '%colors NoColor']

        Expect.__init__(self,
                        name='sage',
                        prompt=prompt,
                        command=command,
                        restart_on_ctrlc=False,
                        logfile=logfile,
                        init_code=init_code,
                        server=server,
                        server_tmpdir=server_tmpdir,
                        remote_cleaner=remote_cleaner,
                        **kwds)
        self._preparse = preparse
コード例 #38
0
    def __init__(self,
                 maxread=100,
                 script_subdirectory=None,
                 server=None,
                 server_tmpdir=None,
                 logfile=None,
                 ulimit=None):
        """
        Create an instance of the Maple interpreter.

        EXAMPLES::

            sage: maple == loads(dumps(maple))
            True
        """
        __maple_iface_opts = [
            'screenwidth=infinity',
            'errorcursor=false',
        ]
        __maple_command = 'maple -t -c "interface({})"'.format(
            ','.join(__maple_iface_opts))
        #errorcursor=false avoids maple command line interface to dump
        #into the editor when an error occurs. Thus pexpect interface
        #is not messed up if a maple error occurs.
        #screenwidth=infinity prevents maple command interface from cutting
        #your input lines. By doing this, file interface also works in the
        #event that  sage_user_home + sage_tmp_file_stuff exceeds the
        #length of 79 characters.
        Expect.__init__(self,
                        name='maple',
                        prompt='#-->',
                        command=__maple_command,
                        server=server,
                        server_tmpdir=server_tmpdir,
                        ulimit=ulimit,
                        maxread=maxread,
                        script_subdirectory=script_subdirectory,
                        restart_on_ctrlc=False,
                        verbose_start=False,
                        logfile=logfile,
                        eval_using_file_cutoff=2048)  # 2048 is
コード例 #39
0
ファイル: reduce.py プロジェクト: pombredanne/spd_notebook
    def __init__(self,
                 maxread=100000, script_subdirectory=None,
                 logfile=None,
                 server=None,
                 server_tmpdir=None):
        Expect.__init__(self,

                        # The capitalized versionof this is used for printing.
                        name = 'reduce',

                        # This is regexp of the input prompt.  If you can change
                        # it to be very obfuscated that would be better.   Even
                        # better is to use sequence numbers. 
                        prompt = '[1-9]: ',

                        # This is the command that starts up your program
                        command = "reduce",

                        maxread = maxread,
                        server=server,
                        server_tmpdir=server_tmpdir,
                        script_subdirectory = script_subdirectory,

                        # If this is true, then whenever the user presses Control-C to
                        # interrupt a calculation, the whole interface is restarted. 
                        restart_on_ctrlc = False,

                        # If true, print out a message when starting
                        # up the command when you first send a command
                        # to this interface.
                        verbose_start = False,

                        init_code=['off int$'],

                        logfile=logfile,

                        # If an input is longer than this number of characters, then
                        # try to switch to outputing to a file. 
                        eval_using_file_cutoff=1024)
        
        self.__seq = 0
コード例 #40
0
 def __init__(self, maxread=100, script_subdirectory="", server=None, server_tmpdir=None, logfile=None):
     """
     Create an instance of the Maple interpreter.
     
     EXAMPLES::
     
         sage: maple == loads(dumps(maple))
         True
     """
     Expect.__init__(self,
                     name = 'maple',
                     prompt = '#-->',
                     command = "maple -t",
                     maxread = maxread,
                     script_subdirectory = script_subdirectory,
                     restart_on_ctrlc = False,
                     server = server,
                     server_tmpdir = server_tmpdir,
                     verbose_start = False,
                     logfile = logfile,
                     eval_using_file_cutoff=1)  # very important that this is 1
コード例 #41
0
    def __init__(self, stacksize=10000000,   # 10MB
                 maxread=100000, script_subdirectory=None,
                 logfile=None,
                 server=None,
                 server_tmpdir=None,
                 init_list_length=1024):
        """
        Initialization of this PARI gp interpreter.

        INPUT:

        - ``stacksize`` (int, default 10000000) -- the initial PARI
          stacksize in bytes (default 10MB)
        - ``maxread`` (int, default 100000) -- ??
        - ``script_subdirectory`` (string, default None) -- name of the subdirectory of SAGE_ROOT/data/extcode/pari from which to read scripts
        - ``logfile`` (string, default None) -- log file for the pexpect interface
        - ``server`` -- name of remote server
        - ``server_tmpdir`` -- name of temporary directory on remote server
        - ``init_list_length`` (int, default 1024) -- length of initial list of local variables.

        EXAMPLES::
        
            sage: gp == loads(dumps(gp))
            True
        """
        Expect.__init__(self,
                        name = 'pari',
                        prompt = '\\? ',
                        command = "gp --emacs --quiet --stacksize %s"%stacksize,
                        maxread = maxread,
                        server=server,
                        server_tmpdir=server_tmpdir,
                        script_subdirectory = script_subdirectory,
                        restart_on_ctrlc = False,
                        verbose_start = False,
                        logfile=logfile,
                        eval_using_file_cutoff=1024)
        self.__seq = 0
        self.__var_store_len = 0
        self.__init_list_length = init_list_length
コード例 #42
0
ファイル: reduce.py プロジェクト: bopopescu/spd_notebook
    def __init__(self,
                 maxread=100000,
                 script_subdirectory=None,
                 logfile=None,
                 server=None,
                 server_tmpdir=None):
        Expect.__init__(
            self,

            # The capitalized versionof this is used for printing.
            name='reduce',

            # This is regexp of the input prompt.  If you can change
            # it to be very obfuscated that would be better.   Even
            # better is to use sequence numbers.
            prompt='[1-9]: ',

            # This is the command that starts up your program
            command="reduce",
            maxread=maxread,
            server=server,
            server_tmpdir=server_tmpdir,
            script_subdirectory=script_subdirectory,

            # If this is true, then whenever the user presses Control-C to
            # interrupt a calculation, the whole interface is restarted.
            restart_on_ctrlc=False,

            # If true, print out a message when starting
            # up the command when you first send a command
            # to this interface.
            verbose_start=False,
            init_code=['off int$'],
            logfile=logfile,

            # If an input is longer than this number of characters, then
            # try to switch to outputing to a file.
            eval_using_file_cutoff=1024)

        self.__seq = 0
コード例 #43
0
ファイル: sage0.py プロジェクト: wdv4758h/sage
    def __init__(self,
                 logfile=None,
                 preparse=True,
                 python=False,
                 init_code=None,
                 server=None,
                 server_tmpdir=None,
                 remote_cleaner=True,
                 **kwds):
        """
        EXAMPLES::

            sage: sage0 == loads(dumps(sage0))
            True
        """
        if python:
            command = "python -u"
            prompt = ">>>"
            if init_code is None:
                init_code = ['from sage.all import *', 'import cPickle']
        else:
            # Disable the IPython history (implemented as SQLite database)
            # to avoid problems with locking.
            command = "sage-ipython --HistoryManager.hist_file=:memory: --colors=NoColor"
            prompt = "sage: "
            if init_code is None:
                init_code = ['import cPickle']

        Expect.__init__(self,
                        name='sage',
                        prompt=prompt,
                        command=command,
                        restart_on_ctrlc=False,
                        logfile=logfile,
                        init_code=init_code,
                        server=server,
                        server_tmpdir=server_tmpdir,
                        remote_cleaner=remote_cleaner,
                        **kwds)
        self._preparse = preparse
コード例 #44
0
ファイル: gap.py プロジェクト: pombredanne/spd_notebook
 def __init__(self, max_workspace_size=None,
              maxread=100000, script_subdirectory=None,
              use_workspace_cache = True,
              server=None,
              server_tmpdir=None,
              logfile = None):
     """
     EXAMPLES::
     
         sage: gap == loads(dumps(gap))
         True
     """
     if os.uname()[-1] == 'ia64':
         # workspace cache is buggy on Itanium in GAP-4.4.12 -- see #5455.
         use_workspace_cache = False
     self.__use_workspace_cache = use_workspace_cache
     cmd, self.__make_workspace = gap_command(use_workspace_cache, server is None)
     cmd += " -b -p -T"
     if max_workspace_size != None:
         cmd += " -o %s"%int(max_workspace_size)
     else: # unlimited
         if is_64_bit:
             cmd += " -o 9999G"  
         else:
             cmd += " -o 3900m"
     cmd += " %s/extcode/gap/sage.g"%DB_HOME    
     Expect.__init__(self,
                     name = 'gap',
                     prompt = 'gap> ',
                     command = cmd,
                     maxread = maxread,
                     server = server,
                     server_tmpdir = server_tmpdir,
                     script_subdirectory = script_subdirectory,
                     restart_on_ctrlc = True,
                     verbose_start = False,
                     logfile = logfile,
                     eval_using_file_cutoff=100)
     self.__seq = 0
コード例 #45
0
ファイル: kash.py プロジェクト: bgxcpku/sagelib
    def __init__(self,
                 max_workspace_size=None,
                 maxread=100000,
                 script_subdirectory=None,
                 restart_on_ctrlc = True,
                 logfile=None,
                 server=None,
                 server_tmpdir=None):

        """
        INPUT:
            max_workspace_size -- (default: None)
                    set maximal workspace memory usage to <mem>
                    <mem> stands for byte-wise allocation
                    <mem>k stands for kilobyte-wise allocation
                    <mem>m stands for megabyte-wise allocation
        """


        cmd = "kash3 -b -c -d  "
        if max_workspace_size != None:
            cmd += " -a %s"%int(max_workspace)
        Expect.__init__(self,
                        name = 'kash',
                        prompt = 'kash% ',
                        command = cmd,
                        maxread = maxread,
                        server = server,
                        server_tmpdir = server_tmpdir,
                        script_subdirectory = script_subdirectory,
                        restart_on_ctrlc = True,
                        verbose_start = False,
                        logfile = logfile,
                        eval_using_file_cutoff=100,
                        init_code = ['X:=ZX.1;']
                        )
        # The above init_code programs around a bug reported by Jack Schmidt

        self.__seq = 0
コード例 #46
0
 def __init__(self,
              maxread=10000,
              script_subdirectory="",
              logfile=None,
              server=None,
              server_tmpdir=None):
     """
     TESTS:
         sage: macaulay2 == loads(dumps(macaulay2))
         True
     """
     Expect.__init__(self,
                     name='macaulay2',
                     prompt='i[0-9]* : ',
                     command="M2 --no-debug --no-readline --silent ",
                     maxread=maxread,
                     server=server,
                     server_tmpdir=server_tmpdir,
                     script_subdirectory=script_subdirectory,
                     verbose_start=False,
                     logfile=logfile,
                     eval_using_file_cutoff=500)
コード例 #47
0
ファイル: scilab.py プロジェクト: pombredanne/sage-1
    def __init__(self, maxread=100, script_subdirectory="", logfile=None, server=None, server_tmpdir=None):
        """
        Initializes the Scilab class.

        EXAMPLES:
            sage: from sage.interfaces.scilab import Scilab
            sage: sci_obj = Scilab(script_subdirectory='user')  # optional - scilab
            sage: del sci_obj                                   # optional - scilab
        """
        Expect.__init__(
            self,
            name="scilab",
            prompt="-->",
            command="scilab -nogui",
            maxread=maxread,
            server=server,
            server_tmpdir=server_tmpdir,
            script_subdirectory=script_subdirectory,
            restart_on_ctrlc=False,
            verbose_start=False,
            logfile=logfile,
            eval_using_file_cutoff=100,
        )
コード例 #48
0
ファイル: axiom.py プロジェクト: pombredanne/spd_notebook
 def __init__(self, script_subdirectory=None, logfile=None, server=None, server_tmpdir=None):
     """
     Create an instance of the Axiom interpreter.
     
     TESTS::
     
         sage: axiom == loads(dumps(axiom))
         True
     """
     eval_using_file_cutoff = 200
     self.__eval_using_file_cutoff = eval_using_file_cutoff
     Expect.__init__(self,
                     name = 'axiom',
                     prompt = '\([0-9]+\) -> ',
                     command = "axiom -nox -noclef",
                     maxread = 10, 
                     script_subdirectory = script_subdirectory,
                     server=server,
                     server_tmpdir=server_tmpdir,
                     restart_on_ctrlc = False,
                     verbose_start = False,
                     #init_code = [')lisp (si::readline-off)'],
                     logfile = logfile,
                     eval_using_file_cutoff=eval_using_file_cutoff)
コード例 #49
0
ファイル: maxima.py プロジェクト: sensen1/sage
    def __init__(self, script_subdirectory=None, logfile=None, server=None,
                 init_code=None):
        """
        Create an instance of the Maxima interpreter.

        TESTS::

            sage: Maxima == loads(dumps(Maxima))
            True
            sage: maxima == loads(dumps(maxima))
            True

        Unpickling a Maxima Pexpect interface gives the default interface::

            sage: m = Maxima()
            sage: maxima == loads(dumps(m))
            True

        We make sure labels are turned off (see :trac:`6816`)::

            sage: 'nolabels : true' in maxima._Expect__init_code
            True
        """
        # TODO: Input and output prompts in maxima can be changed by
        # setting inchar and outchar..
        eval_using_file_cutoff = 256
        self.__eval_using_file_cutoff = eval_using_file_cutoff
        STARTUP = os.path.join(SAGE_LOCAL,'bin','sage-maxima.lisp')

        # We set maxima's configuration directory to $DOT_SAGE/maxima
        # This avoids that sage's maxima inadvertently loads
        # ~/.maxima/maxima-init.mac
        # If you absolutely want maxima instances that are started by
        # this interface to preload commands, put them in
        # $DOT_SAGE/maxima/maxima-init.mac
        # (we use the "--userdir" option in maxima for this)
        SAGE_MAXIMA_DIR = os.path.join(DOT_SAGE,"maxima")

        if not os.path.exists(STARTUP):
            raise RuntimeError('You must get the file local/bin/sage-maxima.lisp')

        #self.__init_code = init_code
        if init_code is None:
            # display2d -- no ascii art output
            # keepfloat -- don't automatically convert floats to rationals
            init_code = ['display2d : false', 'keepfloat : true']

        # Turn off the prompt labels, since computing them *very
        # dramatically* slows down the maxima interpret after a while.
        # See the function makelabel in suprv1.lisp.
        # Many thanks to [email protected] and also
        # Robert Dodier for figuring this out!
        # See trac # 6818.
        init_code.append('nolabels : true')

        MaximaAbstract.__init__(self,"maxima")
        Expect.__init__(self,
                        name = 'maxima',
                        prompt = '\(\%i[0-9]+\) ',
                        command = 'maxima --userdir="%s" -p "%s"'%(SAGE_MAXIMA_DIR,STARTUP),
                        maxread = 10000,
                        script_subdirectory = script_subdirectory,
                        restart_on_ctrlc = False,
                        verbose_start = False,
                        init_code = init_code,
                        logfile = logfile,
                        eval_using_file_cutoff=eval_using_file_cutoff)
        # Must match what is in the file local/bin/sage-maxima.lisp
        self._display_prompt = '<sage-display>'
        # See #15440 for the importance of the trailing space
        self._output_prompt_re = re.compile('\(\%o[0-9]+\) ')
        self._ask = ['zero or nonzero\\?', 'an integer\\?',
                     'positive, negative or zero\\?', 'positive or negative\\?',
                     'positive or zero\\?', 'equal to .*\\?']
        self._prompt_wait = [self._prompt] + [re.compile(x) for x in self._ask] + \
                            ['Break [0-9]+'] #note that you might need to change _expect_expr if you
                                             #change this
        self._error_re = re.compile('(Principal Value|debugmode|incorrect syntax|Maxima encountered a Lisp error)')
        self._display2d = False
コード例 #50
0
    def __init__(self, script_subdirectory=None, logfile=None, server=None,
                 init_code = None):
        """
        Create an instance of the Maxima interpreter.

        TESTS::

            sage: Maxima == loads(dumps(Maxima))
            True
            sage: maxima == loads(dumps(maxima))
            True

        Unpickling a Maxima Pexpect interface gives the default interface::

            sage: m = Maxima()
            sage: maxima == loads(dumps(m))
            True

        We make sure labels are turned off (see trac 6816)::

            sage: 'nolabels : true' in maxima._Expect__init_code
            True
        """
        # TODO: Input and output prompts in maxima can be changed by
        # setting inchar and outchar..
        eval_using_file_cutoff = 256
        self.__eval_using_file_cutoff = eval_using_file_cutoff
        STARTUP = os.path.join(SAGE_LOCAL,'bin','sage-maxima.lisp')

        # We set maxima's configuration directory to $DOT_SAGE/maxima
        # This avoids that sage's maxima inadvertently loads
        # ~/.maxima/maxima-init.mac
        # If you absolutely want maxima instances that are started by
        # this interface to preload commands, put them in
        # $DOT_SAGE/maxima/maxima-init.mac
        # (we use the "--userdir" option in maxima for this)
        SAGE_MAXIMA_DIR = os.path.join(DOT_SAGE,"maxima")

        if not os.path.exists(STARTUP):
            raise RuntimeError, 'You must get the file local/bin/sage-maxima.lisp'

        #self.__init_code = init_code
        if init_code is None:
            # display2d -- no ascii art output
            # keepfloat -- don't automatically convert floats to rationals
            init_code = ['display2d : false', 'keepfloat : true']

        # Turn off the prompt labels, since computing them *very
        # dramatically* slows down the maxima interpret after a while.
        # See the function makelabel in suprv1.lisp.
        # Many thanks to [email protected] and also
        # Robert Dodier for figuring this out!
        # See trac # 6818.
        init_code.append('nolabels : true')

        MaximaAbstract.__init__(self,"maxima")
        Expect.__init__(self,
                        name = 'maxima',
                        prompt = '\(\%i[0-9]+\)',
                        command = 'maxima --userdir="%s" -p "%s"'%(SAGE_MAXIMA_DIR,STARTUP),
                        maxread = 10000,
                        script_subdirectory = script_subdirectory,
                        restart_on_ctrlc = False,
                        verbose_start = False,
                        init_code = init_code,
                        logfile = logfile,
                        eval_using_file_cutoff=eval_using_file_cutoff)
        self._display_prompt = '<sage-display>'  # must match what is in the file local/bin/sage-maxima.lisp!!
        self._output_prompt_re = re.compile('\(\%o[0-9]+\)')
        self._ask = ['zero or nonzero?', 'an integer?', 'positive, negative, or zero?',
                     'positive or negative?', 'positive or zero?']
        self._prompt_wait = [self._prompt] + [re.compile(x) for x in self._ask] + \
                            ['Break [0-9]+'] #note that you might need to change _expect_expr if you
                                             #change this
        self._error_re = re.compile('(Principal Value|debugmode|incorrect syntax|Maxima encountered a Lisp error)')
        self._display2d = False