Changeset 7482:8e9e9c966222
- Timestamp:
- 12/01/07 21:26:37 (5 years ago)
- Branch:
- default
- Location:
- sage
- Files:
-
- 3 edited
-
interfaces/magma.py (modified) (1 diff)
-
interfaces/maxima.py (modified) (8 diffs)
-
server/notebook/js.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sage/interfaces/magma.py
r7230 r7482 253 253 raise AttributeError 254 254 return MagmaFunction(self, attrname) 255 256 def chdir(self, dir): 257 """ 258 Change the Magma interpreters current working directory. 259 260 EXAMPLES: 261 sage: magma.eval('System("pwd")') # optional and random 262 '/Users/was/s/devel/sage-main/sage' 263 sage: magma.chdir('..') # optional 264 sage: magma.eval('System("pwd")') # optional and random 265 '/Users/was/s/devel/sage-main' 266 """ 267 self.eval('ChangeDirectory("%s")'%dir, strip=False) 255 268 256 269 def eval(self, x, strip=True): -
sage/interfaces/maxima.py
r7188 r7482 607 607 self.quit() 608 608 609 609 610 ########################################### 611 # System -- change directory, etc 612 ########################################### 613 def chdir(self, dir): 614 """ 615 Change Maxima's current working directory. 616 617 EXAMPLES: 618 sage: maxima.chdir('/') 619 """ 620 self.lisp('(ext::cd "%s")'%dir) 621 622 ########################################### 623 # Direct access to underlying lisp interpreter. 624 ########################################### 625 def lisp(self, cmd): 626 """ 627 Send a lisp command to maxima. 628 629 NOTE: The output of this command is very raw -- not pretty. 630 631 EXAMPLES: 632 sage: maxima.lisp("(+ 2 17)") # random formated output 633 :lisp (+ 2 17) 634 19 635 ( 636 """ 637 self._eval_line(':lisp %s\n""'%cmd, allow_use_file=False, wait_for_prompt=False, reformat=False, error_check=False) 638 self._expect_expr('(%i)') 639 return self._before() 610 640 611 641 ########################################### … … 675 705 676 706 def trait_names(self, verbose=True, use_disk_cache=True): 707 """ 708 Return all Maxima commands, which is useful for tab completion. 709 710 EXAMPLES: 711 sage: len(maxima.trait_names(verbose=False)) # random output 712 1743 713 """ 677 714 try: 678 715 return self.__trait_names … … 696 733 697 734 def _object_class(self): 735 """ 736 Return the Python class of Maxima elements. 737 738 EXAMPLES: 739 sage: maxima._object_class() 740 <class 'sage.interfaces.maxima.MaximaElement'> 741 """ 698 742 return MaximaElement 699 743 700 744 def _true_symbol(self): 745 """ 746 Return the true symbol in Maxima. 747 748 EXAMPLES: 749 sage: maxima._true_symbol() 750 'true' 751 sage: maxima.eval('is(2 = 2)') 752 'true' 753 """ 701 754 return 'true' 702 755 703 756 def _false_symbol(self): 757 """ 758 Return the false symbol in Maxima. 759 760 EXAMPLES: 761 sage: maxima._false_symbol() 762 'false' 763 sage: maxima.eval('is(2 = 4)') 764 'false' 765 """ 704 766 return 'false' 705 767 … … 796 858 797 859 def console(self): 860 r""" 861 Start the interactive Maxima console. This is a completely separate maxima 862 session from this interface. To interact with this session, you should 863 instead use \code{maxima.interact()}. 864 865 EXAMPLES: 866 sage: maxima.console() # not tested (since we can't) 867 Maxima 5.13.0 http://maxima.sourceforge.net 868 Using Lisp CLISP 2.41 (2006-10-13) 869 Distributed under the GNU Public License. See the file COPYING. 870 Dedicated to the memory of William Schelter. 871 This is a development version of Maxima. The function bug_report() 872 provides bug reporting information. 873 (%i1) 874 875 sage: maxima.interact() # this is not tested either 876 --> Switching to Maxima <-- 877 maxima: 2+2 878 4 879 maxima: 880 --> Exiting back to SAGE <-- 881 """ 798 882 maxima_console() 799 883 800 884 def version(self): 885 """ 886 Return the version of Maxima that Sage includes. 887 888 EXAMPLES: 889 sage: maxima.version() 890 '5.13.0' 891 """ 801 892 return maxima_version() 802 893 … … 1207 1298 # the comparison thus when no comparable in interfaced system. 1208 1299 1209 def sage_object(self): 1210 from sage.calculus.calculus import symbolic_expression_from_maxima_string 1211 return symbolic_expression_from_maxima_string(self.name(), maxima=self.parent()) 1212 1213 def numer(self): 1214 return self.comma('numer') 1215 1216 def real(self): 1217 return self.realpart() 1218 1219 def imag(self): 1220 return self.imagpart() 1221 1222 def _complex_mpfr_field_(self, CC): 1300 def _sage_(self): 1301 """ 1302 Attempt to make a native Sage object out of this maxima object. This is useful 1303 for automatic coercions in addition to other things. 1304 1305 EXAMPLES: 1306 sage: a = maxima('sqrt(2) + 2.5'); a 1307 sqrt(2)+2.5 1308 sage: b = a._sage_(); b 1309 sqrt(2) + 2.50000000000000 1310 sage: type(b) 1311 <class 'sage.calculus.calculus.SymbolicArithmetic'> 1312 1313 We illustrate an automatic coercion: 1314 sage: c = b + sqrt(3); c 1315 sqrt(3) + sqrt(2) + 2.50000000000000 1316 sage: type(c) 1317 <class 'sage.calculus.calculus.SymbolicArithmetic'> 1318 sage: d = sqrt(3) + b; d 1319 sqrt(3) + sqrt(2) + 2.50000000000000 1320 sage: type(d) 1321 <class 'sage.calculus.calculus.SymbolicArithmetic'> 1322 """ 1323 from sage.calculus.calculus import symbolic_expression_from_maxima_string 1324 #return symbolic_expression_from_maxima_string(self.name(), maxima=self.parent()) 1325 return symbolic_expression_from_maxima_string(repr(self)) 1326 1327 def _complex_mpfr_field_(self, C): 1223 1328 """ 1224 1329 EXAMPLES: … … 1229 1334 sage: ComplexField(10)(maxima('2342.23482943872+234*%i')) 1230 1335 2300. + 230.*I 1231 """ 1232 return sage.rings.complex_number.ComplexNumber( CC, self.real(), self.imag() ) 1336 sage: ComplexField(200)(maxima('1+%i')) 1337 1.0000000000000000000000000000000000000000000000000000000000 + 1.0000000000000000000000000000000000000000000000000000000000*I 1338 sage: ComplexField(200)(maxima('sqrt(-2)')) 1339 1.4142135623730950488016887242096980785696718753769480731767*I 1340 sage: N(sqrt(-2), 200) 1341 1.4142135623730950488016887242096980785696718753769480731767*I 1342 """ 1343 return C(self._sage_()) 1344 1345 def _mpfr_(self, R): 1346 """ 1347 EXAMPLES: 1348 sage: RealField(100)(maxima('sqrt(2)+1')) 1349 2.4142135623730950488016887242 1350 """ 1351 return R(self._sage_()) 1352 1353 def _complex_double_(self, C): 1354 """ 1355 EXAMPLES: 1356 sage: CDF(maxima('sqrt(2)+1')) 1357 2.41421356237 1358 """ 1359 return C(self._sage_()) 1360 1361 def _real_double_(self, R): 1362 """ 1363 EXAMPLES: 1364 sage: RDF(maxima('sqrt(2)+1')) 1365 2.41421356237 1366 """ 1367 return R(self._sage_()) 1368 1369 def numer(self): 1370 """ 1371 Return numerical approximation to self as a Maxima object. 1372 1373 EXAMPLES: 1374 sage: a = maxima('sqrt(2)').numer(); a 1375 1.414213562373095 1376 sage: type(a) 1377 <class 'sage.interfaces.maxima.MaximaElement'> 1378 """ 1379 return self.comma('numer') 1233 1380 1234 1381 def str(self): 1382 """ 1383 Return string representation of this maxima object. 1384 1385 EXAMPLES: 1386 sage: maxima('sqrt(2) + 1/3').str() 1387 'sqrt(2)+1/3' 1388 """ 1235 1389 P = self._check_valid() 1236 1390 return P.get(self._name) 1237 1391 1238 1392 def __repr__(self): 1393 """ 1394 Return print representation of this object. 1395 1396 EXAMPLES: 1397 sage: maxima('sqrt(2) + 1/3').__repr__() 1398 'sqrt(2)+1/3' 1399 """ 1239 1400 P = self._check_valid() 1240 1401 try: … … 1491 1652 1492 1653 def subst(self, val): 1654 """ 1655 Substitute a value or several values into this Maxima object. 1656 1657 EXAMPLES: 1658 sage: maxima('a^2 + 3*a + b').subst('b=2') 1659 a^2+3*a+2 1660 sage: maxima('a^2 + 3*a + b').subst('a=17') 1661 b+340 1662 sage: maxima('a^2 + 3*a + b').subst('a=17, b=2') 1663 342 1664 """ 1493 1665 return self.comma(val) 1494 1666 1495 1667 def comma(self, args): 1668 """ 1669 Form the expression that would be written 'self, args' in Maxima. 1670 1671 EXAMPLES: 1672 sage: maxima('sqrt(2) + I').comma('numer') 1673 I+1.414213562373095 1674 sage: maxima('sqrt(2) + I*a').comma('a=5') 1675 5*I+sqrt(2) 1676 """ 1496 1677 self._check_valid() 1497 1678 P = self.parent() … … 1499 1680 1500 1681 def _latex_(self): 1682 """ 1683 Return Latex representation of this Maxima object. 1684 1685 This calls the tex command in Maxima, then does a little ` 1686 post-processing to fix bugs in the resulting Maxima output. 1687 1688 EXAMPLES: 1689 sage: maxima('sqrt(2) + 1/3 + asin(5)')._latex_() 1690 '\\sin^{-1}\\cdot5+\\sqrt{2}+{{1}\\over{3}}' 1691 """ 1501 1692 self._check_valid() 1502 1693 P = self.parent() -
sage/server/notebook/js.py
r7400 r7482 901 901 with(theform) { 902 902 var system = options[selectedIndex].value; 903 if (confirm("A re you sure you wish to change the evaluation system to " + system + "? All cells will be evaluted using " + system + " until you change the system back.")) {903 if (confirm("All cells will be evaluted using " + system + " until you change the system back.")) { 904 904 system_select(system); 905 905 } else {
Note: See TracChangeset
for help on using the changeset viewer.
