Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
a2b3fa86
Commit
a2b3fa86
authored
1 year ago
by
Petter Källström
Browse files
Options
Downloads
Patches
Plain Diff
plot_window: Updated Oscars suggestions, and some more.
parent
eba4e307
No related branches found
No related tags found
1 merge request
!312
Draft: Added support for plotting result from many simulations. Solves #209
Pipeline
#96343
failed
1 year ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
b_asic/gui_utils/plot_window.py
+43
-28
43 additions, 28 deletions
b_asic/gui_utils/plot_window.py
with
43 additions
and
28 deletions
b_asic/gui_utils/plot_window.py
+
43
−
28
View file @
a2b3fa86
...
...
@@ -275,6 +275,16 @@ class PlotWindow(QWidget):
markers
=
"
.ov<^>s+*xd|_
"
ix
=
0
self
.
_auto_redraw
=
False
def
addline
(
key
,
vector
,
checked
):
line
=
self
.
_plot_axes
.
plot
(
np
.
real
(
res
),
fmt
,
label
=
key
)
self
.
_lines
[
key
]
=
line
[
0
]
list_item
=
QListWidgetItem
(
key
)
list_item
.
setCheckState
(
Qt
.
CheckState
.
Unchecked
)
# will add it if checked
self
.
_checklist
.
addItem
(
list_item
)
self
.
_lines
[
key
].
remove
()
# remove the line from plot. Keep it in _lines.
list_item
.
setCheckState
(
checked
)
# will add it if checked
for
key
,
res
in
result
.
items
():
key2
=
name
+
"
.
"
+
key
ischecked
=
Qt
.
CheckState
.
Unchecked
...
...
@@ -288,19 +298,6 @@ class PlotWindow(QWidget):
else
:
fmt
=
'
-
'
def
addline
(
key
,
vector
,
checked
):
line
=
self
.
_plot_axes
.
plot
(
np
.
real
(
res
),
fmt
,
label
=
key
)
self
.
_lines
[
key
]
=
line
[
0
]
list_item
=
QListWidgetItem
(
key
)
list_item
.
setCheckState
(
Qt
.
CheckState
.
Unchecked
)
# will add it if checked
self
.
_checklist
.
addItem
(
list_item
)
self
.
_lines
[
key
].
remove
()
# remove the line from plot. Keep it in _lines.
list_item
.
setCheckState
(
checked
)
# will add it if checked
if
all
(
np
.
imag
(
np
.
real_if_close
(
res
))
==
0
):
# real: add one line with corresponding checkbox
addline
(
key2
,
np
.
real
(
res
),
ischecked
)
...
...
@@ -368,13 +365,16 @@ class PlotWindow(QWidget):
def
start_simulation_dialog
(
sim_results
:
Dict
[
str
,
List
[
complex
]],
sfg_name
:
Optional
[
str
]
=
None
):
"""
Deprecated. Use `show_simulation_result` instead.
"""
"""
deprecated::
Use :func:`show_simulation_result` instead.
"""
show_simulation_result
(
sim_results
,
sfg_name
)
def
show_simulation_result
(
sim_results
:
Dict
[
str
,
List
[
complex
]],
figure_name
:
Optional
[
str
]
=
None
):
)
->
PlotWindow
:
"""
Display the simulation results window.
...
...
@@ -385,6 +385,12 @@ def show_simulation_result(
Alternative, sim_result can be a list, [
'
name1
'
, sim_result1,
'
name2
'
, sim_result2, ...]
figure_name : str, optional
The name of the SFG.
Note: This starts the GUI event loop using `QApplication.instance().exec()`, and the function
will return when the window is closed.
If this is not desired, you can in ipython start the event loop using `%gui qt`, and define
a global variable `noqtexec = 1`.
Effect if no event loop is running: The windows turns black and do not reponse.
Effect if the event loop is started twice: The function will never return.
"""
if
not
QApplication
.
instance
():
app
=
QApplication
(
sys
.
argv
)
...
...
@@ -392,10 +398,19 @@ def show_simulation_result(
app
=
QApplication
.
instance
()
win
=
PlotWindow
(
sim_result
=
sim_results
,
figure_name
=
figure_name
)
win
.
show
()
app
.
exec_
()
# I did not get "if 'noqtexec' in globals()" to work. Try this instead:
try
:
if
noqtexec
!=
1
:
raise
NameError
()
except
NameError
:
app
.
exec
()
return
win
# Simple test of the dialog
from
time
import
sleep
if
__name__
==
"
__main__
"
:
res1
=
{
'
0
'
:
[
1.5
,
1.6
,
1.5
,
1
],
...
...
@@ -422,18 +437,18 @@ if __name__ == "__main__":
'
t3
'
:
[
0
,
0
,
0
,
1
],
}
res3
=
{
#'0': np.random.rand(50).tolist(),
'
0
'
:
np
.
random
.
rand
(
50
),
'
1
'
:
np
.
random
.
rand
(
200
).
tolist
(),
}
res4
=
{
'
0
'
:
np
.
random
.
rand
(
60
).
tolist
(),
'
1
'
:
np
.
random
.
rand
(
220
).
tolist
(),
'
t4
'
:
np
.
random
.
rand
(
50
).
tolist
(),
}
# start_simulation_dialog(res3)
app
=
QApplication
(
sys
.
argv
)
win2
=
PlotWindow
([
'
Real
'
,
res1
,
'
Cpx
'
,
res2
,
res3
],
"
Test data
"
)
win2
.
add_result
(
'
res4
'
,
res4
)
win2
.
show
()
app
.
exec_
()
# res4 = {
# '0': np.random.rand(60).tolist(),
# '1': np.random.rand(220).tolist(),
# 't4': np.random.rand(50).tolist(),
# }
win
=
show_simulation_result
([
'
r1
'
,
res1
,
res2
])
try
:
if
noqtexec
==
1
:
sleep
(
5
)
win
.
add_result
(
'
hej
'
,
res3
)
except
NameError
:
pass
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