Skip to content

Commit 36837e4

Browse files
committed
mypy fix. typo in function call. remove has_side_effects for Which
1 parent 45c302b commit 36837e4

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

mathics/builtin/procedural.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,6 @@ class Which(SympyFunction):
717717
"""
718718

719719
attributes = A_HOLD_ALL | A_PROTECTED
720-
has_side_effects = True
721720
summary_text = "test which of a sequence of conditions are true"
722721

723722
def eval(self, items, evaluation):

mathics/core/convert/function.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Callable, Optional, Tuple
44

55
from mathics.core.definitions import SIDE_EFFECT_BUILTINS, Definition
6-
from mathics.core.element import BaseElement
6+
from mathics.core.element import BaseElement, EvalMixin
77
from mathics.core.evaluation import Evaluation
88
from mathics.core.expression import Expression, from_python
99
from mathics.core.symbols import Symbol, SymbolFalse, SymbolTrue
@@ -47,8 +47,8 @@ def __init__(self, var):
4747

4848

4949
def evaluate_without_side_effects(
50-
expr: BaseElement, evaluation: Evaluation
51-
) -> BaseElement:
50+
expr: Expression, evaluation: Evaluation
51+
) -> Expression:
5252
"""
5353
Evaluate an expression leaving unevaluated subexpressions
5454
related with side-effects (assignments, loops).
@@ -69,7 +69,7 @@ def evaluate_without_side_effects(
6969
# Restore the definitions
7070
for name, defin in SIDE_EFFECT_BUILTINS.items():
7171
definitions.builtin[name] = defin
72-
return result
72+
return result if result is not None else expr
7373

7474

7575
def expression_to_callable(
@@ -84,7 +84,8 @@ def expression_to_callable(
8484
args: a list of CompileArg elements
8585
evaluation: an Evaluation object used if the llvm compilation fails
8686
"""
87-
expr = evaluate_without_side_effects(expr, evaluation)
87+
if evaluation is not None:
88+
expr = evaluate_without_side_effects(expr, evaluation)
8889
try:
8990
cfunc = _compile(expr, args) if (use_llvm and args is not None) else None
9091
except CompileError:

mathics/eval/drawing/plot_compile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def plot_compile(evaluation, expr, names, debug=0):
5555
# because some functions are not themselves sympy-enabled
5656
# if they always get rewritten to one that is.
5757
try:
58-
new_expr = eval_without_side_effects(expr, evaluation)
58+
new_expr = evaluate_without_side_effects(expr, evaluation)
5959
if new_expr:
6060
expr = new_expr
6161
except Exception:

0 commit comments

Comments
 (0)