Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Frederik Hennig
pystencils
Commits
1bb35b83
Commit
1bb35b83
authored
Mar 28, 2022
by
Markus Holzer
Committed by
Jan Hönig
Mar 28, 2022
Browse files
Bug fix simplification
parent
69ec458c
Changes
2
Hide whitespace changes
Inline
Side-by-side
pystencils/sympyextensions.py
View file @
1bb35b83
...
...
@@ -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
else
:
if
current_expr
.
func
==
sp
.
Mul
and
Zero
()
in
param_list
:
return
Zero
(
)
return
sp
.
simplify
(
current_expr
)
else
:
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
else
:
return
sp
.
Rational
(
0
,
1
)
return
Zero
(
)
if
type
(
expr
)
!=
Add
:
return
expr
...
...
pystencils_tests/test_timeloop.py
View file @
1bb35b83
...
...
@@ -59,4 +59,6 @@ def test_timeloop():
timeloop
.
run_time_span
(
seconds
=
seconds
)
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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment