@@ -1095,6 +1095,7 @@ class Re(SympyFunction):
10951095 """
10961096
10971097 attributes = ("Listable" , "NumericFunction" )
1098+ sympy_name = "re"
10981099
10991100 def apply_complex (self , number , evaluation ):
11001101 "Re[number_Complex]"
@@ -1209,7 +1210,7 @@ class Abs(_MPMathFunction):
12091210 mpmath_name = "fabs" # mpmath actually uses python abs(x) / x.__abs__()
12101211
12111212
1212- class Sign (Builtin ):
1213+ class Sign (SympyFunction ):
12131214 """
12141215 <dl>
12151216 <dt>'Sign[$x$]'
@@ -1237,8 +1238,7 @@ class Sign(Builtin):
12371238 = Sign[20]
12381239 """
12391240
1240- # Sympy and mpmath do not give the desired form of complex number
1241- # sympy_name = 'sign'
1241+ sympy_name = "sign"
12421242 # mpmath_name = 'sign'
12431243
12441244 attributes = ("Listable" , "NumericFunction" )
@@ -1248,14 +1248,15 @@ class Sign(Builtin):
12481248 }
12491249
12501250 def apply (self , x , evaluation ):
1251- "Sign[x_]"
1251+ "%(name)s[x_]"
1252+ # Sympy and mpmath do not give the desired form of complex number
12521253 if isinstance (x , Complex ):
12531254 return Expression ("Times" , x , Expression ("Power" , Expression ("Abs" , x ), - 1 ))
12541255
12551256 sympy_x = x .to_sympy ()
12561257 if sympy_x is None :
12571258 return None
1258- return from_sympy ( sympy . sign ( sympy_x ) )
1259+ return super (). apply ( x )
12591260
12601261 def apply_error (self , x , seqs , evaluation ):
12611262 "Sign[x_, seqs__]"
@@ -1591,7 +1592,7 @@ class Rational_(Builtin):
15911592 name = "Rational"
15921593
15931594 def apply (self , n , m , evaluation ):
1594- "Rational [n_Integer, m_Integer]"
1595+ "%(name)s [n_Integer, m_Integer]"
15951596
15961597 if m .to_sympy () == 1 :
15971598 return Integer (n .to_sympy ())
@@ -1658,7 +1659,7 @@ class Complex_(Builtin):
16581659 name = "Complex"
16591660
16601661 def apply (self , r , i , evaluation ):
1661- "Complex [r_?NumberQ, i_?NumberQ]"
1662+ "%(name)s [r_?NumberQ, i_?NumberQ]"
16621663
16631664 if isinstance (r , Complex ) or isinstance (i , Complex ):
16641665 sym_form = r .to_sympy () + sympy .I * i .to_sympy ()
@@ -2063,7 +2064,7 @@ class Piecewise(SympyFunction):
20632064 attributes = ("HoldAll" ,)
20642065
20652066 def apply (self , items , evaluation ):
2066- "Piecewise [items__]"
2067+ "%(name)s [items__]"
20672068 result = self .to_sympy (Expression ("Piecewise" , * items .get_sequence ()))
20682069 if result is None :
20692070 return
@@ -2129,7 +2130,7 @@ class Boole(Builtin):
21292130 attributes = ("Listable" ,)
21302131
21312132 def apply (self , expr , evaluation ):
2132- "Boole [expr_]"
2133+ "%(name)s [expr_]"
21332134 if isinstance (expr , Symbol ):
21342135 if expr == SymbolTrue :
21352136 return Integer (1 )
0 commit comments