Skip to content
Snippets Groups Projects

Address #13: Use sympy.codegen.rewriting.optimize

Merged Stephan Seitz requested to merge seitz/pystencils:use_codegen.rewriting.optimize into master
Viewing commit 7e32d75c
Show latest version
1 file
+ 2
3
Preferences
Compare changes
@@ -9,7 +9,6 @@ import itertools
from pystencils import Assignment
from pystencils.astnodes import SympyAssignment
from pystencils.integer_functions import IntegerFunctionTwoArgsMixIn
try:
from sympy.codegen.rewriting import optims_c99, optimize
@@ -18,7 +17,7 @@ try:
# Evaluates all constant terms
evaluate_constant_terms = ReplaceOptim(
lambda e: hasattr(e, 'is_constant') and e.is_constant,
lambda e: hasattr(e, 'is_constant') and e.is_constant and not e.is_integer,
lambda p: p.evalf()
)
@@ -38,7 +37,7 @@ def optimize_assignments(assignments, optimizations):
if HAS_REWRITING:
assignments = [Assignment(a.lhs, optimize(a.rhs, optimizations))
if hasattr(a, 'lhs') and not a.rhs.atoms(IntegerFunctionTwoArgsMixIn)
if hasattr(a, 'lhs')
else a for a in assignments]
assignments_nodes = [a.atoms(SympyAssignment) for a in assignments]
for a in itertools.chain.from_iterable(assignments_nodes):