Skip to content

Commit

Permalink
Refactor suggestion-internal-modules (kubeflow#1106)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-bata authored and alfred.xx committed Apr 7, 2020
1 parent 5f8b432 commit 5cf25dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions pkg/suggestion/v1alpha3/internal/search_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions pkg/suggestion/v1alpha3/internal/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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(
Expand Down

0 comments on commit 5cf25dd

Please sign in to comment.