Пример #1
0
    def eval(self, code, strip=True, **kwds):
        """
        EXAMPLES:
            sage: mupad.eval('2+2')   # optional - mupad
                                                   4

        """
        s = Expect.eval(self, code, **kwds)
        return AsciiArtString(s)
Пример #2
0
 def help(self, s):
     """
     EXAMPLES:
         sage: macaulay2.help("load")  # optional
         load -- read Macaulay2 commands
         *******************************
         ...
           * "input" -- read Macaulay2 commands and echo
           * "notify" -- whether to notify the user when a file is loaded
     """
     r = self.eval("help %s" % s)
     end = r.rfind("\n\nDIV")
     if end != -1:
         r = r[:end]
     return AsciiArtString(r)
Пример #3
0
    def version(self):
        """
        Returns the version of Lisp being used.

        EXAMPLES:
            sage: lisp.version()
            GNU CLISP ... (...) (built ...)
            ...

        """
        import subprocess
        p = subprocess.Popen('clisp --version',
                             shell=True,
                             stdin=subprocess.PIPE,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        return AsciiArtString(p.stdout.read())
Пример #4
0
    def function_call(self, function, args=None, kwds=None):
        """
        EXAMPLES:
            sage: lie.function_call("diagram", args=['A4']) # optional - lie
            O---O---O---O
            1   2   3   4
            A4
        """
        #If function just prints something on the screen rather than
        #returning an object, then we return an AsciiArtString rather
        #than a LiEElement
        if function in ['diagram', 'setdefault', 'print_tab', 'type', 'factor', 'void', 'gcol']:
            args, kwds = self._convert_args_kwds(args, kwds)
            cmd = "%s(%s)"%(function, ",".join([s.name() for s in args]))
            return AsciiArtString(self.eval(cmd))

        return Expect.function_call(self, function, args, kwds)
Пример #5
0
    def eval(self, code, strip=True, **kwds):
        """
        Send the code x to the Macaulay2 interpreter and return the output
        as a string suitable for input back into Macaulay2, if possible.

        INPUT:
            code -- str
            strip -- ignored

        EXAMPLES:
            sage: macaulay2.eval("2+2") #optional
            4
        """
        code = code.strip()
        # TODO: in some cases change toExternalString to toString??
        ans = Expect.eval(self, code, strip=strip, **kwds).strip('\n')
        if strip:
            ans = remove_output_labels(ans)
        return AsciiArtString(ans)
Пример #6
0
 def help(self, s):
     """
     EXAMPLES:
         sage: macaulay2.help("gb") #optional
         help(gb)
         ...
         gb -- compute a Groebner basis
         ******************************
         ...
         * gb(Matrix)
         * gb(Module)    
     """
     import re
     div = re.compile("o[0-9]+ : DIV")
     if self._expect is None:
         self._start()
     E = self._expect
     E.sendline("help(%s)" % s)
     E.expect(div)
     s = E.before
     E.expect(self._prompt)
     return AsciiArtString(s)
Пример #7
0
 def eval(self, code, strip=True, **kwds):
     s = Expect.eval(self, code, **kwds)
     if strip:
         return AsciiArtString(clean_output(s))
     else:
         return AsciiArtString(s)