Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.measure
Commits
afab8ae0
Commit
afab8ae0
authored
Apr 25, 2018
by
Theophile GENTILHOMME
Browse files
Bins can now be givens for each histogram in the figure
parent
b2dc1d84
Pipeline
#19454
passed with stage
in 42 minutes and 37 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/measure/script/common_options.py
View file @
afab8ae0
...
...
@@ -174,16 +174,19 @@ def n_bins_option(**kwargs):
def
callback
(
ctx
,
param
,
value
):
if
value
is
None
:
value
=
'auto'
elif
value
<
2
:
raise
click
.
BadParameter
(
'Number of bins must be greater than 1'
,
ctx
=
ctx
)
else
:
tmp
=
value
.
split
(
','
)
try
:
value
=
[
int
(
i
)
if
i
!=
'auto'
else
i
for
i
in
tmp
]
except
Exception
:
raise
click
.
BadParameter
(
'Incorrect number of bins inputs'
)
ctx
.
meta
[
'n_bins'
]
=
value
return
value
return
click
.
option
(
'-b'
,
'--nbins'
,
type
=
INT
,
default
=
None
,
help
=
'The number of bins in the histogram(s). Default: `auto`'
,
'-b'
,
'--nbins'
,
type
=
click
.
STRING
,
default
=
'auto'
,
help
=
'The number of bins for the different histograms in the '
' figure, seperated by commas. For example, if three histograms '
'are in the plots, input something like `100,auto,50`'
,
callback
=
callback
,
**
kwargs
)(
func
)
return
custom_n_bins_option
...
...
bob/measure/script/figure.py
View file @
afab8ae0
...
...
@@ -520,7 +520,7 @@ class Hist(PlotBase):
''' Functional base class for histograms'''
def
__init__
(
self
,
ctx
,
scores
,
evaluation
,
func_load
):
super
(
Hist
,
self
).
__init__
(
ctx
,
scores
,
evaluation
,
func_load
)
self
.
_nbins
=
None
if
'n_bins'
not
in
ctx
.
meta
else
ctx
.
meta
[
'n_bins'
]
self
.
_nbins
=
[]
if
'n_bins'
not
in
ctx
.
meta
else
ctx
.
meta
[
'n_bins'
]
self
.
_thres
=
None
if
'thres'
not
in
ctx
.
meta
else
ctx
.
meta
[
'thres'
]
self
.
_show_dev
=
((
not
self
.
_eval
)
if
'show_dev'
not
in
ctx
.
meta
else
\
ctx
.
meta
[
'show_dev'
])
or
not
self
.
_eval
...
...
@@ -621,9 +621,11 @@ class Hist(PlotBase):
)
if
self
.
_thres
is
None
else
self
.
_thres
[
idx
]
return
dev_neg
,
dev_pos
,
eval_neg
,
eval_pos
,
threshold
def
_density_hist
(
self
,
scores
,
**
kwargs
):
def
_density_hist
(
self
,
scores
,
n
,
**
kwargs
):
n
,
bins
,
patches
=
mpl
.
hist
(
scores
,
density
=
True
,
bins
=
self
.
_nbins
,
**
kwargs
scores
,
density
=
True
,
bins
=
'auto'
if
len
(
self
.
_nbins
)
<=
n
else
self
.
_nbins
[
n
],
**
kwargs
)
return
(
n
,
bins
,
patches
)
...
...
@@ -638,8 +640,11 @@ class Hist(PlotBase):
def
_setup_hist
(
self
,
neg
,
pos
):
''' This function can be overwritten in derived classes'''
self
.
_density_hist
(
pos
[
0
],
label
=
'Positives'
,
alpha
=
0.5
,
color
=
'C0'
neg
[
0
],
n
=
0
,
label
=
'Negatives'
,
alpha
=
0.5
,
color
=
'C3'
)
self
.
_density_hist
(
neg
[
0
],
label
=
'Negatives'
,
alpha
=
0.5
,
color
=
'C3'
pos
[
0
],
n
=
1
,
label
=
'Positives'
,
alpha
=
0.5
,
color
=
'C0'
)
bob/measure/test_script.py
View file @
afab8ae0
...
...
@@ -132,14 +132,14 @@ def test_hist():
with
runner
.
isolated_filesystem
():
result
=
runner
.
invoke
(
commands
.
hist
,
[
'--no-evaluation'
,
'--criterion'
,
'hter'
,
'--output'
,
'HISTO.pdf'
,
'-b'
,
30
,
dev1
,
dev2
])
'
30,
100'
,
dev1
,
dev2
])
if
result
.
output
:
click
.
echo
(
result
.
output
)
assert
result
.
exit_code
==
0
,
(
result
.
exit_code
,
result
.
output
)
with
runner
.
isolated_filesystem
():
result
=
runner
.
invoke
(
commands
.
hist
,
[
'--criterion'
,
'eer'
,
'--output'
,
'HISTO.pdf'
,
'-b'
,
30
,
'HISTO.pdf'
,
'-b'
,
'
30,
20'
,
dev1
,
test1
,
dev2
,
test2
])
if
result
.
output
:
click
.
echo
(
result
.
output
)
...
...
@@ -159,7 +159,7 @@ def test_evaluate():
with
runner
.
isolated_filesystem
():
result
=
runner
.
invoke
(
commands
.
evaluate
,
[
'--no-evaluation'
,
'--output'
,
'my_plots.pdf'
,
'-b'
,
30
,
'-n'
,
300
,
dev1
,
dev2
])
'
30,
69'
,
'-n'
,
300
,
dev1
,
dev2
])
assert
result
.
exit_code
==
0
,
(
result
.
exit_code
,
result
.
output
)
with
runner
.
isolated_filesystem
():
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment