Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.measure
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.measure
Commits
3a560776
There was a problem fetching the pipeline summary.
Commit
3a560776
authored
7 years ago
by
Theophile GENTILHOMME
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring of boolean based options
parent
0ef4f9a0
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!54
Refactors the score loading and scripts functionality
,
!52
generic plotting script for bob measure
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/measure/script/common_options.py
+34
-42
34 additions, 42 deletions
bob/measure/script/common_options.py
with
34 additions
and
42 deletions
bob/measure/script/common_options.py
+
34
−
42
View file @
3a560776
...
...
@@ -49,56 +49,48 @@ def scores_argument(test_mandatory=False, **kwargs):
)(
func
)
return
custom_scores_argument
def
test_option
(
**
kwargs
):
'''
Get option flag to say if test-scores are provided
'''
def
custom_test_option
(
func
):
def
callback
(
ctx
,
param
,
value
):
ctx
.
meta
[
'
test
'
]
=
value
return
value
return
click
.
option
(
'
-t
'
,
'
--test/--no-test
'
,
default
=
False
,
help
=
'
If set, test scores must be provided
'
,
show_default
=
True
,
callback
=
callback
,
is_eager
=
True
,
**
kwargs
)(
func
)
return
custom_test_option
def
bool_option
(
name
,
short_name
,
desc
,
dflt
=
False
,
**
kwargs
):
'''
Generic provider for boolean options
Parameters
----------
def
cmc_option
(
dflt
=
False
,
**
kwargs
):
'''
Get option flag to say if cmc scores
'''
def
custom_cmc_option
(
func
):
name: str
name of the option
short_name: str
short name for the option
desc: str
short description for the option
dflt: bool or None
Default value
'''
def
custom_bool_option
(
func
):
def
callback
(
ctx
,
param
,
value
):
ctx
.
meta
[
'
cmc
'
]
=
value
ctx
.
meta
[
name
.
replace
(
'
-
'
,
'
_
'
)
]
=
value
return
value
return
click
.
option
(
'
-C
'
,
'
--cmc/--no-cmc
'
,
default
=
dflt
,
help
=
'
If set, CMC score files are provided
'
,
show_default
=
True
,
callback
=
callback
,
is_eager
=
True
,
**
kwargs
)(
func
)
return
custom_cmc_option
'
-
'
+
short_name
,
'
--%s/--no-%s
'
%
(
name
,
name
),
default
=
dflt
,
help
=
desc
,
show_default
=
True
,
callback
=
callback
,
is_eager
=
True
,
**
kwargs
)(
func
)
return
custom_bool_option
def
test_option
(
**
kwargs
):
'''
Get option flag to say if test-scores are provided
'''
return
bool_option
(
'
test
'
,
'
t
'
,
'
If set, test scores must be provided
'
)
def
sep_dev_test_option
(
**
kwargs
):
def
sep_dev_test_option
(
dflt
=
True
,
**
kwargs
):
'''
Get option flag to say if dev and test plots should be in different
plots
'''
def
custom_sep_dev_test_option
(
func
):
def
callback
(
ctx
,
param
,
value
):
ctx
.
meta
[
'
split
'
]
=
value
return
value
return
click
.
option
(
'
-s
'
,
'
--split/--no-split
'
,
default
=
True
,
show_default
=
True
,
help
=
'
If set, test and dev curve in different plots
'
,
callback
=
callback
,
is_eager
=
True
,
**
kwargs
)(
func
)
return
custom_sep_dev_test_option
return
bool_option
(
'
split
'
,
'
s
'
,
'
If set, test and dev curve in different plots
'
,
dflt
)
def
cmc_option
(
**
kwargs
):
'''
Get option flag to say if cmc scores
'''
return
bool_option
(
'
cmc
'
,
'
C
'
,
'
If set, CMC score files are provided
'
)
def
semilogx_option
(
dflt
=
False
,
**
kwargs
):
'''
Option to use semilog X-axis
'''
def
custom_semilogx_option
(
func
):
def
callback
(
ctx
,
param
,
value
):
ctx
.
meta
[
'
semilogx
'
]
=
value
return
value
return
click
.
option
(
'
--semilogx/--std-x
'
,
default
=
dflt
,
show_default
=
True
,
help
=
'
If set, use semilog on X axis
'
,
callback
=
callback
,
**
kwargs
)(
func
)
return
custom_semilogx_option
return
bool_option
(
'
semilogx
'
,
'
G
'
,
'
If set, use semilog on X axis
'
,
dflt
)
def
list_float_option
(
name
,
short_name
,
desc
,
nitems
=
None
,
dflt
=
None
,
**
kwargs
):
'''
Get option to get a list of float f
...
...
@@ -359,12 +351,12 @@ def far_option(**kwargs):
'''
Get option to get far value
'''
def
custom_far_option
(
func
):
def
callback
(
ctx
,
param
,
value
):
if
value
>
1
or
value
<
0
:
if
value
is
not
None
and
(
value
>
1
or
value
<
0
)
:
raise
click
.
BadParameter
(
"
FAR value should be between 0 and 1
"
)
ctx
.
meta
[
'
far_value
'
]
=
value
return
value
return
click
.
option
(
'
-f
'
,
'
--far-value
'
,
type
=
click
.
FLOAT
,
default
=
1e-2
,
'
-f
'
,
'
--far-value
'
,
type
=
click
.
FLOAT
,
default
=
None
,
help
=
'
The FAR value for which to compute metrics
'
,
callback
=
callback
,
show_default
=
True
,
**
kwargs
)(
func
)
return
custom_far_option
...
...
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