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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Christoph Alt
pystencils
Commits
1edb192f
Commit
1edb192f
authored
3 years ago
by
Jan Hönig
Browse files
Options
Downloads
Patches
Plain Diff
Introduced a converting function form AssignmentCollection to NodeCollection.
parent
1cbb3d17
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/node_collection.py
+6
-1
6 additions, 1 deletion
pystencils/node_collection.py
pystencils_tests/test_nodecollection.py
+13
-0
13 additions, 0 deletions
pystencils_tests/test_nodecollection.py
with
19 additions
and
1 deletion
pystencils/node_collection.py
+
6
−
1
View file @
1edb192f
...
@@ -6,9 +6,10 @@ import sympy as sp
...
@@ -6,9 +6,10 @@ import sympy as sp
from
sympy.codegen
import
Assignment
from
sympy.codegen
import
Assignment
from
sympy.codegen.rewriting
import
ReplaceOptim
,
optimize
from
sympy.codegen.rewriting
import
ReplaceOptim
,
optimize
from
pystencils.astnodes
import
Block
,
Node
from
pystencils.astnodes
import
Block
,
Node
,
SympyAssignment
from
pystencils.backends.cbackend
import
CustomCodeNode
from
pystencils.backends.cbackend
import
CustomCodeNode
from
pystencils.functions
import
DivFunc
from
pystencils.functions
import
DivFunc
from
pystencils.simp
import
AssignmentCollection
class
NodeCollection
:
class
NodeCollection
:
...
@@ -28,6 +29,10 @@ class NodeCollection:
...
@@ -28,6 +29,10 @@ class NodeCollection:
self
.
simplification_hints
=
{}
self
.
simplification_hints
=
{}
@staticmethod
def
from_assignment_collection
(
assignment_collection
:
AssignmentCollection
):
return
NodeCollection
([
SympyAssignment
(
a
.
lhs
,
a
.
rhs
)
for
a
in
assignment_collection
.
all_assignments
])
def
evaluate_terms
(
self
):
def
evaluate_terms
(
self
):
evaluate_constant_terms
=
ReplaceOptim
(
evaluate_constant_terms
=
ReplaceOptim
(
lambda
e
:
hasattr
(
e
,
'
is_constant
'
)
and
e
.
is_constant
and
not
e
.
is_integer
,
lambda
e
:
hasattr
(
e
,
'
is_constant
'
)
and
e
.
is_constant
and
not
e
.
is_integer
,
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_nodecollection.py
0 → 100644
+
13
−
0
View file @
1edb192f
import
sympy
as
sp
from
pystencils
import
AssignmentCollection
,
Assignment
from
pystencils.node_collection
import
NodeCollection
from
pystencils.astnodes
import
SympyAssignment
def
test_node_collection_from_assignment_collection
():
x
=
sp
.
symbols
(
'
x
'
)
assignment_collection
=
AssignmentCollection
([
Assignment
(
x
,
2
)])
node_collection
=
NodeCollection
.
from_assignment_collection
(
assignment_collection
)
assert
node_collection
.
all_assignments
[
0
]
==
SympyAssignment
(
x
,
2
)
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