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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils
Commits
6e7e2fc5
Commit
6e7e2fc5
authored
Mar 28, 2018
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
Tests: Memory Bugfix for ipynb-runner
- shortened the longest running tests, moved some configurations to longrun
parent
04cd0614
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
equationcollection/equationcollection.py
+12
-3
12 additions, 3 deletions
equationcollection/equationcollection.py
sympyextensions.py
+3
-2
3 additions, 2 deletions
sympyextensions.py
with
15 additions
and
5 deletions
equationcollection/equationcollection.py
+
12
−
3
View file @
6e7e2fc5
import
sympy
as
sp
import
sympy
as
sp
from
copy
import
deep
copy
from
copy
import
copy
from
pystencils.sympyextensions
import
fastSubs
,
countNumberOfOperations
,
sortEquationsTopologically
from
pystencils.sympyextensions
import
fastSubs
,
countNumberOfOperations
,
sortEquationsTopologically
...
@@ -40,11 +40,20 @@ class EquationCollection(object):
...
@@ -40,11 +40,20 @@ class EquationCollection(object):
return
[]
return
[]
def
copy
(
self
,
mainEquations
=
None
,
subexpressions
=
None
):
def
copy
(
self
,
mainEquations
=
None
,
subexpressions
=
None
):
res
=
deepcopy
(
self
)
res
=
copy
(
self
)
res
.
simplificationHints
=
self
.
simplificationHints
.
copy
()
res
.
subexpressionSymbolNameGenerator
=
copy
(
self
.
subexpressionSymbolNameGenerator
)
if
mainEquations
is
not
None
:
if
mainEquations
is
not
None
:
res
.
mainEquations
=
mainEquations
res
.
mainEquations
=
mainEquations
else
:
res
.
mainEquations
=
self
.
mainEquations
.
copy
()
if
subexpressions
is
not
None
:
if
subexpressions
is
not
None
:
res
.
subexpressions
=
subexpressions
res
.
subexpressions
=
subexpressions
else
:
res
.
subexpressions
=
self
.
subexpressions
.
copy
()
return
res
return
res
def
copyWithSubstitutionsApplied
(
self
,
substitutionDict
,
addSubstitutionsAsSubexpressions
=
False
,
def
copyWithSubstitutionsApplied
(
self
,
substitutionDict
,
addSubstitutionsAsSubexpressions
=
False
,
...
@@ -103,7 +112,7 @@ class EquationCollection(object):
...
@@ -103,7 +112,7 @@ class EquationCollection(object):
@property
@property
def
operationCount
(
self
):
def
operationCount
(
self
):
"""
See :func:`countNumberOfOperations`
"""
"""
See :func:`countNumberOfOperations`
"""
return
countNumberOfOperations
(
self
.
allEquations
)
return
countNumberOfOperations
(
self
.
allEquations
,
onlyType
=
None
)
def
get
(
self
,
symbols
,
fromMainEquationsOnly
=
False
):
def
get
(
self
,
symbols
,
fromMainEquationsOnly
=
False
):
"""
Return the equations which have symbols as left hand sides
"""
"""
Return the equations which have symbols as left hand sides
"""
...
...
This diff is collapsed.
Click to expand it.
sympyextensions.py
+
3
−
2
View file @
6e7e2fc5
...
@@ -420,13 +420,14 @@ def countNumberOfOperations(term, onlyType='real'):
...
@@ -420,13 +420,14 @@ def countNumberOfOperations(term, onlyType='real'):
"""
"""
Counts the number of additions, multiplications and division
Counts the number of additions, multiplications and division
:param term: a sympy term, equation or sequence of terms/equations
:param term: a sympy term, equation or sequence of terms/equations
:param onlyType:
'
real
'
or
'
int
'
to count only operations on these types, or None for all
:return: a dictionary with
'
adds
'
,
'
muls
'
and
'
divs
'
keys
:return: a dictionary with
'
adds
'
,
'
muls
'
and
'
divs
'
keys
"""
"""
result
=
{
'
adds
'
:
0
,
'
muls
'
:
0
,
'
divs
'
:
0
}
result
=
{
'
adds
'
:
0
,
'
muls
'
:
0
,
'
divs
'
:
0
}
if
isinstance
(
term
,
Sequence
):
if
isinstance
(
term
,
Sequence
):
for
element
in
term
:
for
element
in
term
:
r
=
countNumberOfOperations
(
element
)
r
=
countNumberOfOperations
(
element
,
onlyType
)
for
operationName
in
result
.
keys
():
for
operationName
in
result
.
keys
():
result
[
operationName
]
+=
r
[
operationName
]
result
[
operationName
]
+=
r
[
operationName
]
return
result
return
result
...
@@ -469,7 +470,7 @@ def countNumberOfOperations(term, onlyType='real'):
...
@@ -469,7 +470,7 @@ def countNumberOfOperations(term, onlyType='real'):
elif
t
.
is_integer
:
elif
t
.
is_integer
:
pass
pass
elif
t
.
func
is
sp
.
Pow
:
elif
t
.
func
is
sp
.
Pow
:
if
checkType
(
t
):
if
checkType
(
t
.
args
[
0
]
):
visitChildren
=
False
visitChildren
=
False
if
t
.
exp
.
is_integer
and
t
.
exp
.
is_number
:
if
t
.
exp
.
is_integer
and
t
.
exp
.
is_number
:
if
t
.
exp
>=
0
:
if
t
.
exp
>=
0
:
...
...
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
sign in
to comment