Commit 1bb35b83 authored by Markus Holzer's avatar Markus Holzer Committed by Jan Hönig
Browse files

Bug fix simplification

parent 69ec458c
......@@ -235,6 +235,9 @@ def subs_additive(expr: sp.Expr, replacement: sp.Expr, subexpression: sp.Expr,
normalized_replacement_match = normalize_match_parameter(required_match_replacement, len(subexpression.args))
if isinstance(subexpression, sp.Number):
return expr.subs({replacement: subexpression})
def visit(current_expr):
if current_expr.is_Add:
expr_max_length = max(len(current_expr.args), len(subexpression.args))
......@@ -263,7 +266,7 @@ def subs_additive(expr: sp.Expr, replacement: sp.Expr, subexpression: sp.Expr,
return current_expr
if current_expr.func == sp.Mul and Zero() in param_list:
return Zero()
return sp.simplify(current_expr)
return current_expr.func(*param_list, evaluate=False)
......@@ -359,7 +362,7 @@ def remove_higher_order_terms(expr: sp.Expr, symbols: Sequence[sp.Symbol], order
if velocity_factors_in_product(expr) <= order:
return expr
return sp.Rational(0, 1)
return Zero()
if type(expr) != Add:
return expr
......@@ -59,4 +59,6 @@ def test_timeloop():
end = time.perf_counter()
np.testing.assert_almost_equal(seconds, end - start, decimal=2)
# This test case fails often due to time measurements. It is not a good idea to assert here
# np.testing.assert_almost_equal(seconds, end - start, decimal=2)
print("timeloop: ", seconds, " own meassurement: ", end - start)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment