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
0cdb8981
"apps/tutorials/codegen/03_AdvancedLBMCodegen.cpp" did not exist on "68c49ac95b17b69898813b21e754c42154f119fe"
Commit
0cdb8981
authored
7 years ago
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
Removed unused deprecated functions from sympyextensions
parent
2f213e10
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sympyextensions.py
+2
-43
2 additions, 43 deletions
sympyextensions.py
with
2 additions
and
43 deletions
sympyextensions.py
+
2
−
43
View file @
0cdb8981
...
...
@@ -135,40 +135,6 @@ def fast_subs(expression: T, substitutions: Dict,
return
visit
(
expression
)
def
fast_subs_and_normalize
(
expression
,
substitutions
:
Dict
[
sp
.
Expr
,
sp
.
Expr
],
normalize
:
Callable
[[
sp
.
Expr
],
sp
.
Expr
])
->
sp
.
Expr
:
"""
Similar to fast_subs, but calls a normalization function on all substituted terms to save one AST traversal.
"""
def
visit
(
expr
):
if
expr
in
substitutions
:
return
substitutions
[
expr
],
True
if
not
hasattr
(
expr
,
'
args
'
):
return
expr
,
False
param_list
=
[]
substituted
=
False
for
a
in
expr
.
args
:
replaced_expr
,
s
=
visit
(
a
)
param_list
.
append
(
replaced_expr
)
if
s
:
substituted
=
True
if
not
param_list
:
return
expr
,
False
else
:
if
substituted
:
result
,
_
=
visit
(
normalize
(
expr
.
func
(
*
param_list
)))
return
result
,
True
else
:
return
expr
.
func
(
*
param_list
),
False
if
len
(
substitutions
)
==
0
:
return
expression
else
:
res
,
_
=
visit
(
expression
)
return
res
def
subs_additive
(
expr
:
sp
.
Expr
,
replacement
:
sp
.
Expr
,
subexpression
:
sp
.
Expr
,
required_match_replacement
:
Optional
[
Union
[
int
,
float
]]
=
0.5
,
required_match_original
:
Optional
[
Union
[
int
,
float
]]
=
None
)
->
sp
.
Expr
:
...
...
@@ -186,6 +152,8 @@ def subs_additive(expr: sp.Expr, replacement: sp.Expr, subexpression: sp.Expr,
3
*
x
+
3
*
y
+
z
>>>
subs_additive
(
3
*
x
+
3
*
y
+
z
,
replacement
=
k
,
subexpression
=
x
+
y
+
z
,
required_match_original
=
0.5
)
3
*
k
-
2
*
z
>>>
subs_additive
(
3
*
x
+
3
*
y
+
z
,
replacement
=
k
,
subexpression
=
x
+
y
+
z
,
required_match_original
=
2
)
3
*
k
-
2
*
z
Args:
expr: input expression
...
...
@@ -401,15 +369,6 @@ def complete_the_squares_in_exp(expr: sp.Expr, symbols_to_complete: Sequence[sp.
return
result
def
pow2mul
(
expr
):
"""
Convert integer powers in an expression to Muls, like a**2 => a*a.
"""
powers
=
list
(
expr
.
atoms
(
sp
.
Pow
))
if
any
(
not
e
.
is_Integer
for
b
,
e
in
(
i
.
as_base_exp
()
for
i
in
powers
)):
raise
ValueError
(
"
A power contains a non-integer exponent
"
)
substitutions
=
zip
(
powers
,
(
sp
.
Mul
(
*
[
b
]
*
e
,
evaluate
=
False
)
for
b
,
e
in
(
i
.
as_base_exp
()
for
i
in
powers
)))
return
expr
.
subs
(
substitutions
)
def
extract_most_common_factor
(
term
):
"""
Processes a sum of fractions: determines the most common factor and splits term in common factor and rest
"""
coefficient_dict
=
term
.
as_coefficients_dict
()
...
...
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