# 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


1087  1087  return self.eval(var) 
1088  1088  
1089  1089  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  """ 
1090  1095  return self.get(var) 
1091  1096  
1092  1097  def clear(self, var): 
… 
… 

1415  1420  if attrname[:1] == "_": 
1416  1421  raise AttributeError 
1417  1422  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) 
1418  1440  
1419  1441  def hasattr(self, attrname): 
1420  1442  """ 
diff r 2c43adbaac42 r 052c08ccac80 sage/interfaces/maple.py
a

b


185  185  
186  186  More complicated programs should be put in a separate file and 
187  187  loaded. 
 188  
 189  TESTS: 
 190  We 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  
188  199  """ 
189  200  
190  201  ############################################################################# 
… 
… 

201  212  
202  213  from expect import Expect, ExpectElement, ExpectFunction, FunctionElement, gc_disabled 
203  214  
 215  from random import randrange 
 216  
204  217  import pexpect 
205  218  
206   from sage.misc.misc import verbose, DOT_SAGE 
 219  from sage.misc.misc import verbose, DOT_SAGE, tmp_filename 
207  220  from sage.misc.pager import pager 
208  221  
209  222  COMMANDS_CACHE = '%s/maple_commandlist_cache.sobj'%DOT_SAGE 
… 
… 

856  869  
857  870  sage: M = matrix(ZZ, 2, range(1,5)) 
858  871  sage: Mm = maple(M) 
859   sage: Mm == Mm 
 872  sage: Mm == Mm # random output 
860  873  True 
861   sage: Mm < 5 
 874  sage: Mm < 5 # random output 
862  875  True 
863   sage: (Mm < 5) == (M < 5) 
 876  sage: (Mm < 5) == (M < 5) # random output  depends on machine 
864  877  True 
865   sage: 5 < Mm 
 878  sage: 5 < Mm # random output  depends on machine 
866  879  False 
867  880  
868  881  TESTS: 