@@ -317,8 +317,7 @@ def _commands(self):
317
317
i = s .find (start )
318
318
end = "To get more information about"
319
319
j = s .find (end )
320
- s = s [i + len (start ):j ].split ()
321
- return s
320
+ return s [i + len (start ):j ].split ()
322
321
323
322
def _tab_completion (self , verbose = True , use_disk_cache = True ):
324
323
"""
@@ -357,15 +356,15 @@ def _tab_completion(self, verbose=True, use_disk_cache=True):
357
356
print ("To force rebuild later, delete %s." % self ._COMMANDS_CACHE )
358
357
v = self ._commands ()
359
358
360
- #Process we now need process the commands to strip out things which
361
- #are not valid Python identifiers.
359
+ # Process we now need process the commands to strip out things which
360
+ # are not valid Python identifiers.
362
361
valid = re .compile ('[^a-zA-Z0-9_]+' )
363
362
names = [x for x in v if valid .search (x ) is None ]
364
363
365
- #Change everything that ends with ? to _q and
366
- #everything that ends with ! to _e
367
- names += [x [:- 1 ]+ "_q" for x in v if x .endswith ("?" )]
368
- names += [x [:- 1 ]+ "_e" for x in v if x .endswith ("!" )]
364
+ # Change everything that ends with ? to _q and
365
+ # everything that ends with ! to _e
366
+ names += [x [:- 1 ] + "_q" for x in v if x .endswith ("?" )]
367
+ names += [x [:- 1 ] + "_e" for x in v if x .endswith ("!" )]
369
368
370
369
self .__tab_completion = names
371
370
if len (v ) > 200 :
@@ -430,7 +429,7 @@ def _eval_line(self, line, reformat=True, allow_use_file=False,
430
429
if self ._expect is None :
431
430
self ._start ()
432
431
if allow_use_file and self .__eval_using_file_cutoff and \
433
- len (line ) > self .__eval_using_file_cutoff :
432
+ len (line ) > self .__eval_using_file_cutoff :
434
433
return self ._eval_line_using_file (line )
435
434
try :
436
435
E = self ._expect
@@ -458,14 +457,14 @@ def _eval_line(self, line, reformat=True, allow_use_file=False,
458
457
return out
459
458
# out = out.lstrip()
460
459
i = out .find ('\n ' )
461
- out = out [i + 1 :]
460
+ out = out [i + 1 :]
462
461
outs = out .split ("\n " )
463
462
i = 0
464
463
for line in outs :
465
464
line = line .rstrip ()
466
465
if line [:4 ] == ' (' :
467
466
i = line .find ('(' )
468
- i += line [i :].find (')' )+ 1
467
+ i += line [i :].find (')' ) + 1
469
468
if line [i :] == "" :
470
469
i = 0
471
470
outs = outs [1 :]
@@ -598,14 +597,13 @@ def _richcmp_(self, other, op):
598
597
sage: f = axiom('sin(x)'); g = axiom('cos(x)') #optional - axiom
599
598
sage: f == g #optional - axiom
600
599
False
601
-
602
600
"""
603
601
P = self .parent ()
604
- if 'true' in P .eval ("(%s = %s) :: Boolean" % (self .name (),other .name ())):
602
+ if 'true' in P .eval ("(%s = %s) :: Boolean" % (self .name (), other .name ())):
605
603
return rich_to_bool (op , 0 )
606
604
elif 'true' in P .eval ("(%s < %s) :: Boolean" % (self .name (), other .name ())):
607
605
return rich_to_bool (op , - 1 )
608
- elif 'true' in P .eval ("(%s > %s) :: Boolean" % (self .name (),other .name ())):
606
+ elif 'true' in P .eval ("(%s > %s) :: Boolean" % (self .name (), other .name ())):
609
607
return rich_to_bool (op , 1 )
610
608
611
609
return NotImplemented
@@ -622,7 +620,7 @@ def type(self):
622
620
P = self ._check_valid ()
623
621
s = P ._eval_line (self .name ())
624
622
i = s .rfind ('Type:' )
625
- return P (s [i + 5 :].strip ())
623
+ return P (s [i + 5 :].strip ())
626
624
627
625
def __len__ (self ):
628
626
"""
@@ -637,7 +635,7 @@ def __len__(self):
637
635
P = self ._check_valid ()
638
636
s = P .eval ('# %s ' % self .name ())
639
637
i = s .rfind ('Type' )
640
- return int (s [:i - 1 ])
638
+ return int (s [:i - 1 ])
641
639
642
640
def __getitem__ (self , n ):
643
641
r"""
@@ -709,12 +707,12 @@ def _latex_(self):
709
707
i = s .find ('$$' )
710
708
j = s .rfind ('$$' )
711
709
s = s [i + 2 :j ]
712
- s = multiple_replace ({'\r ' :'' , '\n ' :' ' ,
713
- ' \\ sp ' :'^' ,
714
- '\\ arcsin ' :'\\ sin^{-1} ' ,
715
- '\\ arccos ' :'\\ cos^{-1} ' ,
716
- '\\ arctan ' :'\\ tan^{-1} ' },
717
- re .sub (r'\\leqno\(.*?\)' ,'' ,s )) # no eq number!
710
+ s = multiple_replace ({'\r ' : '' , '\n ' : ' ' ,
711
+ ' \\ sp ' : '^' ,
712
+ '\\ arcsin ' : '\\ sin^{-1} ' ,
713
+ '\\ arccos ' : '\\ cos^{-1} ' ,
714
+ '\\ arctan ' : '\\ tan^{-1} ' },
715
+ re .sub (r'\\leqno\(.*?\)' , '' , s )) # no eq number!
718
716
return s
719
717
720
718
def as_type (self , type ):
@@ -753,16 +751,13 @@ def unparsed_input_form(self):
753
751
s = P .eval ('unparse(%s::InputForm)' % self ._name )
754
752
if 'translation error' in s or 'Cannot convert' in s :
755
753
raise NotImplementedError
756
- s = multiple_replace ({'\r \n ' :'' , # fix stupid Fortran-ish
757
- 'DSIN(' :'sin(' ,
758
- 'DCOS(' :'cos(' ,
759
- 'DTAN(' :'tan(' ,
760
- 'DSINH(' :'sinh(' }, s )
761
- r = re .search (r'"(.*)"' ,s )
762
- if r :
763
- return r .groups (0 )[0 ]
764
- else :
765
- return s
754
+ s = multiple_replace ({'\r \n ' : '' , # fix stupid Fortran-ish
755
+ 'DSIN(' : 'sin(' ,
756
+ 'DCOS(' : 'cos(' ,
757
+ 'DTAN(' : 'tan(' ,
758
+ 'DSINH(' : 'sinh(' }, s )
759
+ r = re .search (r'"(.*)"' , s )
760
+ return r .groups (0 )[0 ] if r else s
766
761
767
762
def _sage_ (self ):
768
763
"""
@@ -835,8 +830,8 @@ def _sage_(self):
835
830
from sage .rings .integer_ring import ZZ
836
831
prec = max (self .mantissa ().length ()._sage_ (), 53 )
837
832
R = RealField (prec )
838
- x ,e , b = self .unparsed_input_form ().lstrip ('float(' ).rstrip (')' ).split (',' )
839
- return R (ZZ (x )* ZZ (b )** ZZ (e ))
833
+ x , e , b = self .unparsed_input_form ().lstrip ('float(' ).rstrip (')' ).split (',' )
834
+ return R (ZZ (x ) * ZZ (b )** ZZ (e ))
840
835
elif type == "DoubleFloat" :
841
836
from sage .rings .real_double import RDF
842
837
return RDF (repr (self ))
@@ -850,16 +845,18 @@ def _sage_(self):
850
845
R = PolynomialRing (base_ring , vars )
851
846
return R (self .unparsed_input_form ())
852
847
elif type .startswith ('Fraction' ):
853
- return self .numer ().sage ()/ self .denom ().sage ()
848
+ return self .numer ().sage () / self .denom ().sage ()
854
849
855
- # If all else fails, try using the unparsed input form
850
+ # If all else fails, try using the unparsed input form
856
851
try :
857
852
import sage .misc .sage_eval
858
853
vars = sage .symbolic .ring .var (str (self .variables ())[1 :- 1 ])
859
- if isinstance (vars ,tuple ):
860
- return sage .misc .sage_eval .sage_eval (self .unparsed_input_form (), locals = {str (x ):x for x in vars })
854
+ if isinstance (vars , tuple ):
855
+ return sage .misc .sage_eval .sage_eval (self .unparsed_input_form (),
856
+ locals = {str (x ): x for x in vars })
861
857
else :
862
- return sage .misc .sage_eval .sage_eval (self .unparsed_input_form (), locals = {str (vars ):vars })
858
+ return sage .misc .sage_eval .sage_eval (self .unparsed_input_form (),
859
+ locals = {str (vars ): vars })
863
860
except Exception :
864
861
raise NotImplementedError
865
862
@@ -961,9 +958,10 @@ def is_AxiomElement(x):
961
958
return isinstance (x , AxiomElement )
962
959
963
960
964
- #Instances
961
+ # Instances
965
962
axiom = Axiom (name = 'axiom' )
966
963
964
+
967
965
def reduce_load_Axiom ():
968
966
"""
969
967
Returns the Axiom interface object defined in
@@ -977,6 +975,7 @@ def reduce_load_Axiom():
977
975
"""
978
976
return axiom
979
977
978
+
980
979
def axiom_console ():
981
980
"""
982
981
Spawn a new Axiom command-line session.
0 commit comments