From 5cf25dd8e08992635b136edff72b58bc3614e8dc Mon Sep 17 00:00:00 2001 From: Masashi SHIBATA Date: Tue, 24 Mar 2020 17:32:47 +0900 Subject: [PATCH] Refactor suggestion-internal-modules (#1106) --- .../v1alpha3/internal/search_space.py | 18 +++++++++--------- pkg/suggestion/v1alpha3/internal/trial.py | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/suggestion/v1alpha3/internal/search_space.py b/pkg/suggestion/v1alpha3/internal/search_space.py index 467b84aa60c..02332a4f8dd 100644 --- a/pkg/suggestion/v1alpha3/internal/search_space.py +++ b/pkg/suggestion/v1alpha3/internal/search_space.py @@ -50,12 +50,12 @@ def convertParameter(p): class HyperParameter(object): - def __init__(self, name, type, min, max, list, step): + def __init__(self, name, type_, min_, max_, list_, step): self.name = name - self.type = type - self.min = min - self.max = max - self.list = list + self.type = type_ + self.min = min_ + self.max = max_ + self.list = list_ self.step = step def __str__(self): @@ -67,12 +67,12 @@ def __str__(self): self.name, self.type, ", ".join(self.list)) @staticmethod - def int(name, min, max): - return HyperParameter(name, INTEGER, min, max, [], 0) + def int(name, min_, max_): + return HyperParameter(name, INTEGER, min_, max_, [], 0) @staticmethod - def double(name, min, max, step): - return HyperParameter(name, DOUBLE, min, max, [], step) + def double(name, min_, max_, step): + return HyperParameter(name, DOUBLE, min_, max_, [], step) @staticmethod def categorical(name, lst): diff --git a/pkg/suggestion/v1alpha3/internal/trial.py b/pkg/suggestion/v1alpha3/internal/trial.py index d37111b3832..7534aa29a83 100644 --- a/pkg/suggestion/v1alpha3/internal/trial.py +++ b/pkg/suggestion/v1alpha3/internal/trial.py @@ -20,7 +20,7 @@ def convert(trials): for trial in trials: if trial.status.condition == api.TrialStatus.TrialConditionType.SUCCEEDED: new_trial = Trial.convertTrial(trial) - if new_trial != None: + if new_trial is not None: res.append(Trial.convertTrial(trial)) return res @@ -33,14 +33,14 @@ def convertTrial(trial): target_metric, additional_metrics = Metric.convert( trial.status.observation, metric_name) # If the target_metric is none, ignore the trial. - if target_metric != None: + if target_metric is not None: trial = Trial(trial.name, assignments, target_metric, metric_name, additional_metrics) return trial return None def __str__(self): - if self.name == None: + if self.name is None: return "Trial(assignment: {})".format(", ".join([str(e) for e in self.assignments])) else: return "Trial(assignment: {}, metric_name: {}, metric: {}, additional_metrics: {})".format(