Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera committed Jun 29, 2021
1 parent de14b91 commit ada387b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
1 change: 0 additions & 1 deletion mathics/core/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ def __init__(
self.cache_eval = {}
self.cache_result = False


def parse(self, query):
"Parse a single expression and print the messages."
from mathics.core.parser import MathicsSingleLineFeeder
Expand Down
42 changes: 16 additions & 26 deletions mathics/core/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,7 @@ def from_python(arg):
# return Symbol(arg)
elif isinstance(arg, dict):
entries = [
Expression(
"Rule",
from_python(key),
from_python(arg[key]),
)
for key in arg
Expression("Rule", from_python(key), from_python(arg[key]),) for key in arg
]
return Expression(SymbolList, *entries)
elif isinstance(arg, BaseExpression):
Expand Down Expand Up @@ -1318,11 +1313,10 @@ def evaluate(self, evaluation) -> typing.Union["Expression", "Symbol"]:
# evaluation.cache_result can be set here or from inside the evaluation
# of a branch. Once it is set to false, the result is not cached,
# and hence, not used.
if evaluation.cache_result and (self.get_head_name() in (
"System`Out",
"System`ToBoxes",
"System`MakeBoxes",
)):
if evaluation.cache_result and (
self.get_head_name()
in ("System`Out", "System`ToBoxes", "System`MakeBoxes",)
):
evaluation.cache_result = False

if evaluation.cache_result:
Expand Down Expand Up @@ -1901,21 +1895,17 @@ def thread(self, evaluation, head=None) -> typing.Tuple[bool, "Expression"]:
return True, Expression(head, *leaves)

def is_numeric(self) -> bool:
return (
self._head.get_name()
in system_symbols(
"Sqrt",
"Times",
"Plus",
"Subtract",
"Minus",
"Power",
"Abs",
"Divide",
"Sin",
)
and all(leaf.is_numeric() for leaf in self._leaves)
)
return self._head.get_name() in system_symbols(
"Sqrt",
"Times",
"Plus",
"Subtract",
"Minus",
"Power",
"Abs",
"Divide",
"Sin",
) and all(leaf.is_numeric() for leaf in self._leaves)
# TODO: complete list of numeric functions, or access NumericFunction
# attribute

Expand Down

0 comments on commit ada387b

Please sign in to comment.