Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.rppg.base
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
Model registry
Operate
Environments
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.rppg.base
Commits
e9fcfe1f
Commit
e9fcfe1f
authored
6 years ago
by
Guillaume HEUSCH
Browse files
Options
Downloads
Patches
Plain Diff
[utils] add a function to get parameters from either configuration file or command-line
parent
fe101e24
No related branches found
No related tags found
1 merge request
!6
Resolve "Package depends on both bob.db.cohface and bob.db.hci_tagging"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/rppg/base/utils.py
+43
-0
43 additions, 0 deletions
bob/rppg/base/utils.py
with
43 additions
and
0 deletions
bob/rppg/base/utils.py
+
43
−
0
View file @
e9fcfe1f
...
@@ -99,3 +99,46 @@ def build_bandpass_filter(fs, order, plot=False):
...
@@ -99,3 +99,46 @@ def build_bandpass_filter(fs, order, plot=False):
pyplot
.
show
()
pyplot
.
show
()
return
b
return
b
def
get_parameter
(
args
,
configuration
,
keyword
,
default
):
"""
Get the right value for a parameter
The parameters are either defined in a separate configuration file
or given directly via command-line. Note that the command-line
has priority over the configuration file.
As a convention, parameters made with more than one word
are provided with an underscore in the configuration file, and with an
hyphen in the command-line:
- configuration: batch_size=64
- command line: --batch-size=64
Parameters
----------
args: dictionary
The arguments as parsed from the command line.
configuration: object
The arguments given by the configuration file.
keyword: string
the keyword for the parameter to process (in the
"
configuration
"
style)
default:
The default value of the parameter
Returns
-------
arg:
The right value for the given keyword argument
"""
args_kw
=
'
--
'
+
keyword
.
replace
(
'
_
'
,
'
-
'
)
_type
=
type
(
default
)
arg
=
_type
(
args
[
args_kw
])
if
hasattr
(
configuration
,
keyword
):
arg
=
getattr
(
configuration
,
keyword
)
if
_type
(
args
[
args_kw
])
is
not
default
:
arg
=
_type
(
args
[
args_kw
])
return
arg
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