Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
HearingTest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ed Rogers
HearingTest
Commits
6d01a87d
Commit
6d01a87d
authored
7 years ago
by
Ed Rogers
Browse files
Options
Downloads
Patches
Plain Diff
Improve set_bar_colors for later upgrades
parent
dab5cf61
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
TestWindow.py
+13
-12
13 additions, 12 deletions
TestWindow.py
with
13 additions
and
12 deletions
TestWindow.py
+
13
−
12
View file @
6d01a87d
...
...
@@ -14,8 +14,10 @@ from matplotlib.figure import Figure
class
HearingTestCanvas
(
FigureCanvas
):
"""
Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).
"""
false_color
=
np
.
array
([
0.
,
1.
,
0.
])
true_color
=
np
.
array
([
0.
,
0.
,
1.
])
running_color
=
np
.
array
([
0.
,
1.
,
0.
])
finished_color
=
np
.
array
([
0.
,
0.
,
1.
])
upper_color_depth
=
0.5
lower_color_depth
=
1.0
def
__init__
(
self
,
parent
=
None
,
width
=
5
,
height
=
4
,
dpi
=
100
):
fig
=
Figure
(
figsize
=
(
width
,
height
),
dpi
=
dpi
)
...
...
@@ -39,9 +41,9 @@ class HearingTestCanvas(FigureCanvas):
inds
=
np
.
arange
(
0
,
test
.
freqs
.
size
)
self
.
axes
.
set_facecolor
(
'
k
'
)
self
.
ul_bar
=
self
.
axes
.
bar
(
inds
,
test
.
upper_bounds
-
self
.
baseline
,
color
=
0.5
*
self
.
false
_color
,
bottom
=
self
.
baseline
)
color
=
self
.
upper_color_depth
*
self
.
running
_color
,
bottom
=
self
.
baseline
)
self
.
ll_bar
=
self
.
axes
.
bar
(
inds
,
test
.
lower_bounds
-
self
.
baseline
,
color
=
self
.
false
_color
,
bottom
=
self
.
baseline
)
color
=
self
.
lower_color_depth
*
self
.
running
_color
,
bottom
=
self
.
baseline
)
xlim
=
self
.
axes
.
get_xlim
()
for
i
in
np
.
arange
(
test
.
lower_lim
+
self
.
baseline
,
test
.
upper_lim
,
test
.
block_size
()):
self
.
axes
.
plot
(
self
.
axes
.
get_xlim
(),
np
.
ones
(
2
)
*
i
,
color
=
'
k
'
)
...
...
@@ -55,7 +57,7 @@ class HearingTestCanvas(FigureCanvas):
def
update_test
(
self
,
test
:
HearingTest
)
->
None
:
self
.
set_bar_heights
(
self
.
ul_bar
,
test
.
upper_bounds
-
self
.
baseline
)
self
.
set_bar_heights
(
self
.
ll_bar
,
test
.
lower_bounds
-
self
.
baseline
)
self
.
set_bar_colors
(
[
self
.
ul_bar
,
self
.
ll_bar
],
test
.
finished_freqs
)
self
.
set_bar_colors
(
test
)
self
.
draw
()
@staticmethod
...
...
@@ -63,15 +65,14 @@ class HearingTestCanvas(FigureCanvas):
for
bar
,
h
in
zip
(
bars
,
vals
):
bar
.
set_height
(
h
)
@staticmethod
def
set_bar_colors
(
bars
,
finished
):
depth
=
[
0.5
,
1
]
for
i
,
bar_line
in
enumerate
(
bars
):
for
bar
,
f
in
zip
(
bar_line
,
finished
):
def
set_bar_colors
(
self
,
test
:
HearingTest
)
->
None
:
depth
=
[
self
.
upper_color_depth
,
self
.
lower_color_depth
]
for
i
,
bar_line
in
enumerate
([
self
.
ul_bar
,
self
.
ll_bar
]):
for
bar
,
f
in
zip
(
bar_line
,
test
.
finished_freqs
):
if
f
:
bar
.
set_facecolor
(
depth
[
i
]
*
HearingTestCanvas
.
true
_color
)
bar
.
set_facecolor
(
depth
[
i
]
*
HearingTestCanvas
.
finished
_color
)
else
:
bar
.
set_facecolor
(
depth
[
i
]
*
HearingTestCanvas
.
false
_color
)
bar
.
set_facecolor
(
depth
[
i
]
*
HearingTestCanvas
.
running
_color
)
# TODO add animation
...
...
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