Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor suggestion-internal-modules #1106

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Refactor suggestion-internal-modules
  • Loading branch information
c-bata committed Mar 24, 2020
commit d834eff8961acf1c76489caf6e0881cb60b7fb9e
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):
Copy link
Member Author

@c-bata c-bata Mar 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Python, These are common practices to avoid shadows of built-in methods and variables.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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