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
62ba2144
Commit
62ba2144
authored
1 year ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Test Simulation GUI
parent
f87edabd
No related branches found
No related tags found
1 merge request
!276
Test Simulation GUI
Pipeline
#93827
failed
1 year ago
Stage: test
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/gui_utils/plot_window.py
+20
-8
20 additions, 8 deletions
b_asic/gui_utils/plot_window.py
test/test_simulation_gui.py
+50
-0
50 additions, 0 deletions
test/test_simulation_gui.py
with
70 additions
and
8 deletions
b_asic/gui_utils/plot_window.py
+
20
−
8
View file @
62ba2144
...
@@ -100,8 +100,14 @@ class PlotWindow(QDialog):
...
@@ -100,8 +100,14 @@ class PlotWindow(QDialog):
self
.
_plot_axes
=
self
.
_plot_fig
.
add_subplot
(
111
)
self
.
_plot_axes
=
self
.
_plot_fig
.
add_subplot
(
111
)
self
.
_plot_axes
.
xaxis
.
set_major_locator
(
MaxNLocator
(
integer
=
True
))
self
.
_plot_axes
.
xaxis
.
set_major_locator
(
MaxNLocator
(
integer
=
True
))
# Use | when dropping support for Python 3.8
ordered_for_plotting
=
{}
ordered_for_plotting
.
update
(
sim_res_others
)
ordered_for_plotting
.
update
(
sim_res_delays
)
ordered_for_plotting
.
update
(
sim_res_ins
)
ordered_for_plotting
.
update
(
sim_res_outs
)
self
.
_lines
=
{}
self
.
_lines
=
{}
for
key
in
sim_res_others
|
sim_res_delays
|
sim_res_ins
|
sim_res_outs
:
for
key
,
result
in
ordered_for_plotting
.
items
()
:
line
=
self
.
_plot_axes
.
plot
(
sim_result
[
key
],
label
=
key
)
line
=
self
.
_plot_axes
.
plot
(
sim_result
[
key
],
label
=
key
)
self
.
_lines
[
key
]
=
line
[
0
]
self
.
_lines
[
key
]
=
line
[
0
]
...
@@ -114,12 +120,12 @@ class PlotWindow(QDialog):
...
@@ -114,12 +120,12 @@ class PlotWindow(QDialog):
# Add two buttons for selecting all/none:
# Add two buttons for selecting all/none:
hlayout
=
QHBoxLayout
()
hlayout
=
QHBoxLayout
()
button_all
=
QPushButton
(
"
&All
"
)
self
.
_
button_all
=
QPushButton
(
"
&All
"
)
button_all
.
clicked
.
connect
(
self
.
_button_all_click
)
self
.
_
button_all
.
clicked
.
connect
(
self
.
_button_all_click
)
hlayout
.
addWidget
(
button_all
)
hlayout
.
addWidget
(
self
.
_
button_all
)
button_none
=
QPushButton
(
"
&None
"
)
self
.
_
button_none
=
QPushButton
(
"
&None
"
)
button_none
.
clicked
.
connect
(
self
.
_button_none_click
)
self
.
_
button_none
.
clicked
.
connect
(
self
.
_button_none_click
)
hlayout
.
addWidget
(
button_none
)
hlayout
.
addWidget
(
self
.
_
button_none
)
listlayout
.
addLayout
(
hlayout
)
listlayout
.
addLayout
(
hlayout
)
# Add the entire list
# Add the entire list
...
@@ -127,7 +133,13 @@ class PlotWindow(QDialog):
...
@@ -127,7 +133,13 @@ class PlotWindow(QDialog):
self
.
checklist
.
setSizePolicy
(
QSizePolicy
.
Preferred
,
QSizePolicy
.
Preferred
)
self
.
checklist
.
setSizePolicy
(
QSizePolicy
.
Preferred
,
QSizePolicy
.
Preferred
)
self
.
checklist
.
itemChanged
.
connect
(
self
.
_item_change
)
self
.
checklist
.
itemChanged
.
connect
(
self
.
_item_change
)
listitems
=
{}
listitems
=
{}
for
key
in
sim_res_ins
|
sim_res_outs
|
sim_res_delays
|
sim_res_others
:
# Use | when dropping support for Python 3.8
ordered_for_checklist
=
{}
ordered_for_checklist
.
update
(
sim_res_ins
)
ordered_for_checklist
.
update
(
sim_res_outs
)
ordered_for_checklist
.
update
(
sim_res_delays
)
ordered_for_checklist
.
update
(
sim_res_others
)
for
key
in
ordered_for_checklist
:
listitem
=
QListWidgetItem
(
key
)
listitem
=
QListWidgetItem
(
key
)
listitems
[
key
]
=
listitem
listitems
[
key
]
=
listitem
self
.
checklist
.
addItem
(
listitem
)
self
.
checklist
.
addItem
(
listitem
)
...
...
This diff is collapsed.
Click to expand it.
test/test_simulation_gui.py
0 → 100644
+
50
−
0
View file @
62ba2144
import
pytest
from
qtpy
import
QtCore
try
:
from
b_asic.gui_utils.plot_window
import
PlotWindow
except
ImportError
:
pytestmark
=
pytest
.
mark
.
skip
(
"
Qt not setup
"
)
def
test_start
(
qtbot
):
widget
=
PlotWindow
({})
qtbot
.
addWidget
(
widget
)
def
test_start_with_data
(
qtbot
):
sim_res
=
{
'
0
'
:
[
0.5
,
0.5
,
0
,
0
],
'
add1
'
:
[
0.5
,
0.5
,
0
,
0
],
'
cmul1
'
:
[
0
,
0.5
,
0
,
0
],
'
cmul2
'
:
[
0.5
,
0
,
0
,
0
],
'
in1
'
:
[
1
,
0
,
0
,
0
],
'
t1
'
:
[
0
,
1
,
0
,
0
],
}
widget
=
PlotWindow
(
sim_res
)
qtbot
.
addWidget
(
widget
)
assert
widget
.
checklist
.
count
()
==
6
assert
len
(
widget
.
_plot_axes
.
lines
)
==
1
def
test_click_buttons
(
qtbot
):
sim_res
=
{
'
0
'
:
[
0.5
,
0.5
,
0
,
0
],
'
add1
'
:
[
0.5
,
0.5
,
0
,
0
],
'
cmul1
'
:
[
0
,
0.5
,
0
,
0
],
'
cmul2
'
:
[
0.5
,
0
,
0
,
0
],
'
in1
'
:
[
1
,
0
,
0
,
0
],
'
t1
'
:
[
0
,
1
,
0
,
0
],
}
widget
=
PlotWindow
(
sim_res
)
qtbot
.
addWidget
(
widget
)
assert
widget
.
checklist
.
count
()
==
6
assert
len
(
widget
.
_plot_axes
.
lines
)
==
1
qtbot
.
mouseClick
(
widget
.
_button_all
,
QtCore
.
Qt
.
MouseButton
.
LeftButton
)
assert
len
(
widget
.
_plot_axes
.
lines
)
==
6
qtbot
.
mouseClick
(
widget
.
_button_none
,
QtCore
.
Qt
.
MouseButton
.
LeftButton
)
assert
len
(
widget
.
_plot_axes
.
lines
)
==
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
register
or
sign in
to comment