@@ -318,8 +318,7 @@ def _commands(self):
318
318
i = s .find (start )
319
319
end = "To get more information about"
320
320
j = s .find (end )
321
- s = s [i + len (start ):j ].split ()
322
- return s
321
+ return s [i + len (start ):j ].split ()
323
322
324
323
def _tab_completion (self , verbose = True , use_disk_cache = True ):
325
324
"""
@@ -359,15 +358,15 @@ def _tab_completion(self, verbose=True, use_disk_cache=True):
359
358
print ("To force rebuild later, delete %s." % self ._COMMANDS_CACHE )
360
359
v = self ._commands ()
361
360
362
- #Process we now need process the commands to strip out things which
363
- #are not valid Python identifiers.
361
+ # Process we now need process the commands to strip out things which
362
+ # are not valid Python identifiers.
364
363
valid = re .compile ('[^a-zA-Z0-9_]+' )
365
364
names = [x for x in v if valid .search (x ) is None ]
366
365
367
- #Change everything that ends with ? to _q and
368
- #everything that ends with ! to _e
369
- names += [x [:- 1 ]+ "_q" for x in v if x .endswith ("?" )]
370
- names += [x [:- 1 ]+ "_e" for x in v if x .endswith ("!" )]
366
+ # Change everything that ends with ? to _q and
367
+ # everything that ends with ! to _e
368
+ names += [x [:- 1 ] + "_q" for x in v if x .endswith ("?" )]
369
+ names += [x [:- 1 ] + "_e" for x in v if x .endswith ("!" )]
371
370
372
371
self .__tab_completion = names
373
372
if len (v ) > 200 :
@@ -433,7 +432,7 @@ def _eval_line(self, line, reformat=True, allow_use_file=False,
433
432
if self ._expect is None :
434
433
self ._start ()
435
434
if allow_use_file and self .__eval_using_file_cutoff and \
436
- len (line ) > self .__eval_using_file_cutoff :
435
+ len (line ) > self .__eval_using_file_cutoff :
437
436
return self ._eval_line_using_file (line )
438
437
try :
439
438
E = self ._expect
@@ -468,7 +467,7 @@ def _eval_line(self, line, reformat=True, allow_use_file=False,
468
467
line = line .rstrip ()
469
468
if line [:4 ] == ' (' :
470
469
i = line .find ('(' )
471
- i += line [i :].find (')' )+ 1
470
+ i += line [i :].find (')' ) + 1
472
471
if line [i :] == "" :
473
472
i = 0
474
473
outs = outs [1 :]
@@ -603,14 +602,13 @@ def _richcmp_(self, other, op):
603
602
sage: f = axiom('sin(x)'); g = axiom('cos(x)') #optional - axiom
604
603
sage: f == g #optional - axiom
605
604
False
606
-
607
605
"""
608
606
P = self .parent ()
609
- if 'true' in P .eval ("(%s = %s) :: Boolean" % (self .name (),other .name ())):
607
+ if 'true' in P .eval ("(%s = %s) :: Boolean" % (self .name (), other .name ())):
610
608
return rich_to_bool (op , 0 )
611
609
elif 'true' in P .eval ("(%s < %s) :: Boolean" % (self .name (), other .name ())):
612
610
return rich_to_bool (op , - 1 )
613
- elif 'true' in P .eval ("(%s > %s) :: Boolean" % (self .name (),other .name ())):
611
+ elif 'true' in P .eval ("(%s > %s) :: Boolean" % (self .name (), other .name ())):
614
612
return rich_to_bool (op , 1 )
615
613
616
614
return NotImplemented
@@ -642,7 +640,7 @@ def __len__(self):
642
640
P = self ._check_valid ()
643
641
s = P .eval ('# %s ' % self .name ())
644
642
i = s .rfind ('Type' )
645
- return int (s [:i - 1 ])
643
+ return int (s [:i - 1 ])
646
644
647
645
def __getitem__ (self , n ):
648
646
r"""
@@ -716,12 +714,12 @@ def _latex_(self):
716
714
i = s .find ('$$' )
717
715
j = s .rfind ('$$' )
718
716
s = s [i + 2 :j ]
719
- s = multiple_replace ({'\r ' :'' , '\n ' :' ' ,
720
- ' \\ sp ' :'^' ,
721
- '\\ arcsin ' :'\\ sin^{-1} ' ,
722
- '\\ arccos ' :'\\ cos^{-1} ' ,
723
- '\\ arctan ' :'\\ tan^{-1} ' },
724
- re .sub (r'\\leqno\(.*?\)' ,'' ,s )) # no eq number!
717
+ s = multiple_replace ({'\r ' : '' , '\n ' : ' ' ,
718
+ ' \\ sp ' : '^' ,
719
+ '\\ arcsin ' : '\\ sin^{-1} ' ,
720
+ '\\ arccos ' : '\\ cos^{-1} ' ,
721
+ '\\ arctan ' : '\\ tan^{-1} ' },
722
+ re .sub (r'\\leqno\(.*?\)' , '' , s )) # no eq number!
725
723
return s
726
724
727
725
def as_type (self , type ):
@@ -760,16 +758,13 @@ def unparsed_input_form(self):
760
758
s = P .eval ('unparse(%s::InputForm)' % self ._name )
761
759
if 'translation error' in s or 'Cannot convert' in s :
762
760
raise NotImplementedError
763
- s = multiple_replace ({'\r \n ' :'' , # fix stupid Fortran-ish
764
- 'DSIN(' :'sin(' ,
765
- 'DCOS(' :'cos(' ,
766
- 'DTAN(' :'tan(' ,
767
- 'DSINH(' :'sinh(' }, s )
768
- r = re .search (r'"(.*)"' ,s )
769
- if r :
770
- return r .groups (0 )[0 ]
771
- else :
772
- return s
761
+ s = multiple_replace ({'\r \n ' : '' , # fix stupid Fortran-ish
762
+ 'DSIN(' : 'sin(' ,
763
+ 'DCOS(' : 'cos(' ,
764
+ 'DTAN(' : 'tan(' ,
765
+ 'DSINH(' : 'sinh(' }, s )
766
+ r = re .search (r'"(.*)"' , s )
767
+ return r .groups (0 )[0 ] if r else s
773
768
774
769
def _sage_ (self ):
775
770
"""
@@ -843,8 +838,8 @@ def _sage_(self):
843
838
from sage .rings .integer_ring import ZZ
844
839
prec = max (self .mantissa ().length ()._sage_ (), 53 )
845
840
R = RealField (prec )
846
- x ,e , b = self .unparsed_input_form ().lstrip ('float(' ).rstrip (')' ).split (',' )
847
- return R (ZZ (x )* ZZ (b )** ZZ (e ))
841
+ x , e , b = self .unparsed_input_form ().lstrip ('float(' ).rstrip (')' ).split (',' )
842
+ return R (ZZ (x ) * ZZ (b )** ZZ (e ))
848
843
elif type == "DoubleFloat" :
849
844
from sage .rings .real_double import RDF
850
845
return RDF (repr (self ))
@@ -858,16 +853,18 @@ def _sage_(self):
858
853
R = PolynomialRing (base_ring , vars )
859
854
return R (self .unparsed_input_form ())
860
855
elif type .startswith ('Fraction' ):
861
- return self .numer ().sage ()/ self .denom ().sage ()
856
+ return self .numer ().sage () / self .denom ().sage ()
862
857
863
- # If all else fails, try using the unparsed input form
858
+ # If all else fails, try using the unparsed input form
864
859
try :
865
860
import sage .misc .sage_eval
866
861
vars = sage .symbolic .ring .var (str (self .variables ())[1 :- 1 ])
867
- if isinstance (vars ,tuple ):
868
- return sage .misc .sage_eval .sage_eval (self .unparsed_input_form (), locals = {str (x ):x for x in vars })
862
+ if isinstance (vars , tuple ):
863
+ return sage .misc .sage_eval .sage_eval (self .unparsed_input_form (),
864
+ locals = {str (x ): x for x in vars })
869
865
else :
870
- return sage .misc .sage_eval .sage_eval (self .unparsed_input_form (), locals = {str (vars ):vars })
866
+ return sage .misc .sage_eval .sage_eval (self .unparsed_input_form (),
867
+ locals = {str (vars ): vars })
871
868
except Exception :
872
869
raise NotImplementedError
873
870
@@ -970,9 +967,10 @@ def is_AxiomElement(x):
970
967
return isinstance (x , AxiomElement )
971
968
972
969
973
- #Instances
970
+ # Instances
974
971
axiom = Axiom (name = 'axiom' )
975
972
973
+
976
974
def reduce_load_Axiom ():
977
975
"""
978
976
Returns the Axiom interface object defined in
@@ -986,6 +984,7 @@ def reduce_load_Axiom():
986
984
"""
987
985
return axiom
988
986
987
+
989
988
def axiom_console ():
990
989
"""
991
990
Spawn a new Axiom command-line session.
0 commit comments