flake happy; check_positive() renamed
This commit is contained in:
parent
fc4ef2b430
commit
a429f83f5e
@ -311,7 +311,7 @@ class Arguments(object):
|
|||||||
help='Set random state to some positive integer for reproducible hyperopt results.',
|
help='Set random state to some positive integer for reproducible hyperopt results.',
|
||||||
dest='hyperopt_random_state',
|
dest='hyperopt_random_state',
|
||||||
default=None,
|
default=None,
|
||||||
type=Arguments.check_positive,
|
type=Arguments.check_int_positive,
|
||||||
metavar='INT',
|
metavar='INT',
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -385,13 +385,15 @@ class Arguments(object):
|
|||||||
raise Exception('Incorrect syntax for timerange "%s"' % text)
|
raise Exception('Incorrect syntax for timerange "%s"' % text)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_positive(value) -> int:
|
def check_int_positive(value) -> int:
|
||||||
try:
|
try:
|
||||||
uint = int(value)
|
uint = int(value)
|
||||||
if uint <= 0:
|
if uint <= 0:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
except:
|
except ValueError:
|
||||||
raise argparse.ArgumentTypeError(f"{value} is invalid for this parameter, should be a positive integer value")
|
raise argparse.ArgumentTypeError(
|
||||||
|
f"{value} is invalid for this parameter, should be a positive integer value"
|
||||||
|
)
|
||||||
return uint
|
return uint
|
||||||
|
|
||||||
def scripts_options(self) -> None:
|
def scripts_options(self) -> None:
|
||||||
|
@ -315,7 +315,8 @@ class Configuration(object):
|
|||||||
|
|
||||||
if 'hyperopt_random_state' in self.args and self.args.hyperopt_random_state is not None:
|
if 'hyperopt_random_state' in self.args and self.args.hyperopt_random_state is not None:
|
||||||
config.update({'hyperopt_random_state': self.args.hyperopt_random_state})
|
config.update({'hyperopt_random_state': self.args.hyperopt_random_state})
|
||||||
logger.info("Parameter --random-state detected: %s", config.get('hyperopt_random_state'))
|
logger.info("Parameter --random-state detected: %s",
|
||||||
|
config.get('hyperopt_random_state'))
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user