@@ -126,7 +126,12 @@ def from_python(arg):
126126 # return Symbol(arg)
127127 elif isinstance (arg , dict ):
128128 entries = [
129- Expression ("Rule" , from_python (key ), from_python (arg [key ]),) for key in arg
129+ Expression (
130+ "Rule" ,
131+ from_python (key ),
132+ from_python (arg [key ]),
133+ )
134+ for key in arg
130135 ]
131136 return Expression (SymbolList , * entries )
132137 elif isinstance (arg , BaseExpression ):
@@ -485,7 +490,9 @@ def format_expr(expr):
485490 finally :
486491 evaluation .dec_recursion_depth ()
487492
488- def format (self , evaluation , form ) -> typing .Union ["Expression" , "Symbol" ]:
493+ def format (
494+ self , evaluation , form , ** kwargs
495+ ) -> typing .Union ["Expression" , "Symbol" ]:
489496 """
490497 Applies formats associated to the expression, and then calls Makeboxes
491498 """
@@ -507,7 +514,7 @@ def get_precision(self):
507514 def get_option_values (self , evaluation , allow_symbols = False , stop_on_error = True ):
508515 options = self
509516 if options .has_form ("List" , None ):
510- options = options .flatten (Symbol ( "List" ) )
517+ options = options .flatten (SymbolList )
511518 values = options .leaves
512519 else :
513520 values = [options ]
@@ -1622,9 +1629,9 @@ def filter_leaves(self, head_name):
16221629
16231630 def apply_rules (self , rules , evaluation , level = 0 , options = None ):
16241631 """for rule in rules:
1625- result = rule.apply(self, evaluation, fully=False)
1626- if result is not None:
1627- return result"""
1632+ result = rule.apply(self, evaluation, fully=False)
1633+ if result is not None:
1634+ return result"""
16281635
16291636 # to be able to access it inside inner function
16301637 new_applied = [False ]
@@ -1774,17 +1781,21 @@ def thread(self, evaluation, head=None) -> typing.Tuple[bool, "Expression"]:
17741781 return True , Expression (head , * leaves )
17751782
17761783 def is_numeric (self ) -> bool :
1777- return self ._head .get_name () in system_symbols (
1778- "Sqrt" ,
1779- "Times" ,
1780- "Plus" ,
1781- "Subtract" ,
1782- "Minus" ,
1783- "Power" ,
1784- "Abs" ,
1785- "Divide" ,
1786- "Sin" ,
1787- ) and all (leaf .is_numeric () for leaf in self ._leaves )
1784+ return (
1785+ self ._head .get_name ()
1786+ in system_symbols (
1787+ "Sqrt" ,
1788+ "Times" ,
1789+ "Plus" ,
1790+ "Subtract" ,
1791+ "Minus" ,
1792+ "Power" ,
1793+ "Abs" ,
1794+ "Divide" ,
1795+ "Sin" ,
1796+ )
1797+ and all (leaf .is_numeric () for leaf in self ._leaves )
1798+ )
17881799 # TODO: complete list of numeric functions, or access NumericFunction
17891800 # attribute
17901801
@@ -2054,7 +2065,7 @@ def is_numeric(self) -> bool:
20542065def _ExponentFunction (value ):
20552066 n = value .get_int_value ()
20562067 if - 5 <= n <= 5 :
2057- return Symbol ( "Null" )
2068+ return SymbolNull
20582069 else :
20592070 return value
20602071
0 commit comments