Ticket #2171: sage-trac2171-part1.patch

File sage-trac2171-part1.patch, 3.4 KB (added by William Stein, 14 years ago)
  • sage/interfaces/expect.py

    # HG changeset patch
    # User William Stein <wstein@gmail.com>
    # Date 1224817995 25200
    # Node ID 052c08ccac80b0e102df5ab8fa735fb64df31b9a
    # Parent  2c43adbaac426cfd71d0aba53bb5f5c089bd9253
    trac #2171 -- get_using_file stuff for expect.py
    
    diff -r 2c43adbaac42 -r 052c08ccac80 sage/interfaces/expect.py
    a b  
    10871087        return self.eval(var)
    10881088
    10891089    def get_using_file(self, var):
     1090        """
     1091        Return the string representation of the variable var in self
     1092        using a file.  Use this if var has a huge string
     1093        representation.  It'll be way faster.
     1094        """
    10901095        return self.get(var)
    10911096
    10921097    def clear(self, var):
     
    14151420        if attrname[:1] == "_":
    14161421            raise AttributeError
    14171422        return P._function_element_class()(self, attrname)
     1423
     1424    def get_using_file(self):
     1425        """
     1426        Return this element's string representation using a file.  Use
     1427        this if self has a huge string representation.  It'll be way
     1428        faster.
     1429
     1430        EXAMPLES:
     1431            sage: a = maxima(str(2^1000))
     1432            sage: a.get_using_file()
     1433            '10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376'
     1434        """
     1435        try:
     1436            self._check_valid()
     1437        except ValueError:
     1438            return '(invalid object -- defined in terms of closed session)'
     1439        return self.parent().get_using_file(self._name)
    14181440
    14191441    def hasattr(self, attrname):
    14201442        """
  • sage/interfaces/maple.py

    diff -r 2c43adbaac42 -r 052c08ccac80 sage/interfaces/maple.py
    a b  
    185185       
    186186More complicated programs should be put in a separate file and
    187187loaded.
     188
     189TESTS:
     190We send a fairly large input to Maple and get the output back from Maple.
     191    sage: s = str(3^100000)
     192    sage: len(s)
     193    47713
     194    sage: a = maple(s)      # uses a file to send s to Maple
     195    sage: k = str(a)        # uses a file to get this from Maple
     196    sage: k == s
     197    True
     198
    188199"""
    189200
    190201#############################################################################
     
    201212
    202213from expect import Expect, ExpectElement, ExpectFunction, FunctionElement, gc_disabled
    203214
     215from random import randrange
     216
    204217import pexpect
    205218
    206 from sage.misc.misc import verbose, DOT_SAGE
     219from sage.misc.misc import verbose, DOT_SAGE, tmp_filename
    207220from sage.misc.pager import pager
    208221
    209222COMMANDS_CACHE = '%s/maple_commandlist_cache.sobj'%DOT_SAGE
     
    856869
    857870            sage: M = matrix(ZZ, 2, range(1,5))
    858871            sage: Mm = maple(M)
    859             sage: Mm == Mm
     872            sage: Mm == Mm           # random output
    860873            True
    861             sage: Mm < 5
     874            sage: Mm < 5             # random output
    862875            True
    863             sage: (Mm < 5) == (M < 5)
     876            sage: (Mm < 5) == (M < 5)    # random output -- depends on machine
    864877            True
    865             sage: 5 < Mm
     878            sage: 5 < Mm                # random output -- depends on machine
    866879            False
    867880
    868881        TESTS: