Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils
Commits
4570ee2c
Commit
4570ee2c
authored
3 years ago
by
Jan Hönig
Browse files
Options
Downloads
Plain Diff
Merge branch 'BugFixSimplification' into 'master'
Bug fix simplification See merge request
!290
parents
69ec458c
1bb35b83
Branches
Branches containing commit
No related tags found
1 merge request
!290
Bug fix simplification
Pipeline
#38749
passed
3 years ago
Stage: pretest
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/sympyextensions.py
+5
-2
5 additions, 2 deletions
pystencils/sympyextensions.py
pystencils_tests/test_timeloop.py
+3
-1
3 additions, 1 deletion
pystencils_tests/test_timeloop.py
with
8 additions
and
3 deletions
pystencils/sympyextensions.py
+
5
−
2
View file @
4570ee2c
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_timeloop.py
+
3
−
1
View file @
4570ee2c
...
...
@@ -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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment