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
ce63537a
Commit
ce63537a
authored
7 years ago
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
Moved Qt Stuff into separate file
parent
c598dc78
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
display_utils.py
+0
-49
0 additions, 49 deletions
display_utils.py
qtgui.py
+48
-0
48 additions, 0 deletions
qtgui.py
with
48 additions
and
49 deletions
display_utils.py
+
0
−
49
View file @
ce63537a
import
sys
from
PyQt5.QtWidgets
import
QWidget
,
QApplication
,
QTreeWidget
,
QTreeWidgetItem
,
QHBoxLayout
from
pystencils.astnodes
import
Block
,
LoopOverCoordinate
,
KernelFunction
def
toDot
(
expr
,
graphStyle
=
{}):
"""
Show a sympy or pystencils AST as dot graph
"""
...
...
@@ -48,15 +44,6 @@ def showCode(ast):
return
CodeDisplay
(
ast
)
def
debugGUI
(
ast
):
app
=
QApplication
.
instance
()
if
app
is
None
:
app
=
QApplication
(
sys
.
argv
)
else
:
print
(
'
QApplication instance already exists: %s
'
%
str
(
app
))
ex
=
DebugTree
()
ex
.
insert_ast
(
ast
)
app
.
exec_
()
# ----------------- Embedding of animations as videos in IPython notebooks ---------------------------------------------
...
...
@@ -188,39 +175,3 @@ def makeSurfacePlotAnimation(runFunction, frames=90, interval=30):
return
animation
.
FuncAnimation
(
fig
,
updatefig
,
interval
=
interval
,
frames
=
frames
,
blit
=
False
)
# -------------------- DEBUG GUI ------------------------
class
DebugTree
(
QWidget
):
def
__init__
(
self
):
super
().
__init__
()
self
.
initUI
()
def
initUI
(
self
):
self
.
tree
=
QTreeWidget
(
self
)
self
.
tree
.
setColumnCount
(
1
)
self
.
tree
.
setHeaderLabel
(
'
repr
'
)
hbox
=
QHBoxLayout
()
hbox
.
stretch
(
1
)
hbox
.
addWidget
(
self
.
tree
)
self
.
setWindowTitle
(
'
Debug
'
)
self
.
setLayout
(
hbox
)
self
.
show
()
def
insert_ast
(
self
,
node
,
parent
=
None
):
if
parent
is
None
:
parent
=
self
.
tree
if
isinstance
(
node
,
Block
):
# Blocks are represented with the tree structure
item
=
parent
else
:
item
=
QTreeWidgetItem
(
parent
)
item
.
setText
(
0
,
repr
(
node
))
if
node
.
func
in
[
LoopOverCoordinate
,
KernelFunction
]:
self
.
tree
.
expandItem
(
item
)
for
child
in
node
.
args
:
self
.
insert_ast
(
child
,
item
)
This diff is collapsed.
Click to expand it.
qtgui.py
0 → 100644
+
48
−
0
View file @
ce63537a
import
sys
from
PyQt5.QtWidgets
import
QWidget
,
QApplication
,
QTreeWidget
,
QTreeWidgetItem
,
QHBoxLayout
from
pystencils.astnodes
import
Block
,
LoopOverCoordinate
,
KernelFunction
def
debugGUI
(
ast
):
app
=
QApplication
.
instance
()
if
app
is
None
:
app
=
QApplication
(
sys
.
argv
)
else
:
print
(
'
QApplication instance already exists: %s
'
%
str
(
app
))
ex
=
DebugTree
()
ex
.
insert_ast
(
ast
)
app
.
exec_
()
class
DebugTree
(
QWidget
):
def
__init__
(
self
):
super
().
__init__
()
self
.
initUI
()
def
initUI
(
self
):
self
.
tree
=
QTreeWidget
(
self
)
self
.
tree
.
setColumnCount
(
1
)
self
.
tree
.
setHeaderLabel
(
'
repr
'
)
hbox
=
QHBoxLayout
()
hbox
.
stretch
(
1
)
hbox
.
addWidget
(
self
.
tree
)
self
.
setWindowTitle
(
'
Debug
'
)
self
.
setLayout
(
hbox
)
self
.
show
()
def
insert_ast
(
self
,
node
,
parent
=
None
):
if
parent
is
None
:
parent
=
self
.
tree
if
isinstance
(
node
,
Block
):
# Blocks are represented with the tree structure
item
=
parent
else
:
item
=
QTreeWidgetItem
(
parent
)
item
.
setText
(
0
,
repr
(
node
))
if
node
.
func
in
[
LoopOverCoordinate
,
KernelFunction
]:
self
.
tree
.
expandItem
(
item
)
for
child
in
node
.
args
:
self
.
insert_ast
(
child
,
item
)
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