@@ -294,7 +294,7 @@ class Divisors(Builtin):
294294
295295 # TODO: support GaussianIntegers
296296 # e.g. Divisors[2, GaussianIntegers -> True]
297-
297+
298298 attributes = ('Listable' ,)
299299
300300 def apply (self , n , evaluation ):
@@ -369,102 +369,102 @@ class MantissaExponent(Builtin):
369369
370370 >> MantissaExponent[125., 2]
371371 = {0.976563, 7}
372-
372+
373373 >> MantissaExponent[10, b]
374374 = MantissaExponent[10, b]
375-
375+
376376 #> MantissaExponent[E, Pi]
377377 = {E / Pi, 1}
378-
378+
379379 #> MantissaExponent[Pi, Pi]
380380 = {1 / Pi, 2}
381-
381+
382382 #> MantissaExponent[5/2 + 3, Pi]
383383 = {11 / (2 Pi ^ 2), 2}
384-
384+
385385 #> MantissaExponent[b]
386386 = MantissaExponent[b]
387-
387+
388388 #> MantissaExponent[17, E]
389389 = {17 / E ^ 3, 3}
390-
390+
391391 #> MantissaExponent[17., E]
392392 = {0.84638, 3}
393-
393+
394394 #> MantissaExponent[Exp[Pi], 2]
395395 = {E ^ Pi / 32, 5}
396-
396+
397397 #> MantissaExponent[3 + 2 I, 2]
398398 : The value 3 + 2 I is not a real number
399399 = MantissaExponent[3 + 2 I, 2]
400-
400+
401401 #> MantissaExponent[25, 0.4]
402402 : Base 0.4 is not a real number greater than 1.
403403 = MantissaExponent[25, 0.4]
404-
404+
405405 #> MantissaExponent[0.0000124]
406406 = {0.124, -4}
407-
407+
408408 #> MantissaExponent[0.0000124, 2]
409409 = {0.812646, -16}
410-
410+
411411 #> MantissaExponent[0]
412412 = {0, 0}
413-
413+
414414 #> MantissaExponent[0, 2]
415415 = {0, 0}
416416 """
417-
417+
418418 attributes = ('Listable' ,)
419-
419+
420420 rules = {
421421 'MantissaExponent[0]' : '{0, 0}' ,
422422 'MantissaExponent[0, n_]' : '{0, 0}' ,
423423 }
424-
424+
425425 messages = {
426426 'realx' : 'The value `1` is not a real number' ,
427427 'rbase' : 'Base `1` is not a real number greater than 1.' ,
428428 }
429-
429+
430430 def apply (self , n , b , evaluation ):
431431 'MantissaExponent[n_, b_]'
432432 # Handle Input with special cases such as PI and E
433433 n_sympy , b_sympy = n .to_sympy (), b .to_sympy ()
434-
434+
435435 expr = Expression ('MantissaExponent' , n , b )
436-
436+
437437 if isinstance (n .to_python (), complex ):
438438 evaluation .message ('MantissaExponent' , 'realx' , n )
439439 return expr
440-
440+
441441 if n_sympy .is_constant ():
442442 temp_n = Expression ('N' , n ).evaluate (evaluation )
443443 py_n = temp_n .to_python ()
444444 else :
445445 return expr
446-
446+
447447 if b_sympy .is_constant ():
448448 temp_b = Expression ('N' , b ).evaluate (evaluation )
449449 py_b = temp_b .to_python ()
450450 else :
451451 return expr
452-
452+
453453 if not py_b > 1 :
454454 evaluation .message ('MantissaExponent' , 'rbase' , b )
455455 return expr
456-
456+
457457 base_exp = int (mpmath .log (py_n , py_b ))
458-
458+
459459 exp = (base_exp + 1 ) if base_exp >= 0 else base_exp
460460
461461 return Expression ('List' , Expression ('Divide' , n , b ** exp ), exp )
462-
462+
463463 def apply_2 (self , n , evaluation ):
464464 'MantissaExponent[n_]'
465465 n_sympy = n .to_sympy ()
466466 expr = Expression ('MantissaExponent' , n )
467-
467+
468468 if isinstance (n .to_python (), complex ):
469469 evaluation .message ('MantissaExponent' , 'realx' , n )
470470 return expr
@@ -474,12 +474,12 @@ def apply_2(self, n, evaluation):
474474 py_n = temp_n .to_python ()
475475 else :
476476 return expr
477-
478- base_exp = int (mpmath .log10 (py_n ))
477+
478+ base_exp = int (mpmath .log10 (py_n ))
479479 exp = (base_exp + 1 ) if base_exp >= 0 else base_exp
480-
480+
481481 return Expression ('List' , Expression ('Divide' , n , (10 ** exp )), exp )
482-
482+
483483def _fractional_part (self , n , expr , evaluation ):
484484 n_sympy = n .to_sympy ()
485485 if n_sympy .is_constant ():
@@ -491,9 +491,9 @@ def _fractional_part(self, n, expr, evaluation):
491491 result = n - negative_integer_part
492492 else :
493493 return expr
494-
494+
495495 return from_python (result )
496-
496+
497497class FractionalPart (Builtin ):
498498 """
499499 <dl>
@@ -509,34 +509,34 @@ class FractionalPart(Builtin):
509509
510510 #> FractionalPart[b]
511511 = FractionalPart[b]
512-
512+
513513 #> FractionalPart[{-2.4, -2.5, -3.0}]
514514 = {-0.4, -0.5, 0.}
515-
515+
516516 #> FractionalPart[14/32]
517517 = 7 / 16
518-
518+
519519 #> FractionalPart[4/(1 + 3 I)]
520520 = 2 / 5 - I / 5
521-
521+
522522 #> FractionalPart[Pi^20]
523523 = -8769956796 + Pi ^ 20
524524 """
525-
525+
526526 attributes = ('Listable' , 'NumericFunction' , 'ReadProtected' )
527-
527+
528528 def apply (self , n , evaluation ):
529529 'FractionalPart[n_]'
530530 expr = Expression ('FractionalPart' , n )
531531 return _fractional_part (self .__class__ .__name__ , n , expr , evaluation )
532-
532+
533533 def apply_2 (self , n , evaluation ):
534534 'FractionalPart[n_Complex]'
535535 expr = Expression ('FractionalPart' , n )
536536 n_real = Expression ("Re" , n ).evaluate (evaluation )
537537 n_image = Expression ("Im" , n ).evaluate (evaluation )
538-
539- real_fractional_part = _fractional_part (self .__class__ .__name__ , n_real , expr , evaluation )
538+
539+ real_fractional_part = _fractional_part (self .__class__ .__name__ , n_real , expr , evaluation )
540540 image_fractional_part = _fractional_part (self .__class__ .__name__ , n_image , expr , evaluation )
541541 return Expression ('Complex' , real_fractional_part , image_fractional_part )
542542
@@ -634,7 +634,7 @@ class CoprimeQ(Builtin):
634634 = True
635635
636636 >> CoprimeQ[4+2I, 6+3I]
637- = False
637+ = True
638638
639639 >> CoprimeQ[2, 3, 5]
640640 = True
@@ -964,4 +964,3 @@ def apply(self, m, n, evaluation):
964964 return Expression ('List' , Integer (py_m // py_n ), (py_m % py_n ))
965965 else :
966966 return Expression ('QuotientRemainder' , m , n )
967-
0 commit comments