Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
roussel-ryan committed Nov 4, 2024
1 parent 09c5a36 commit 2275bd1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 1 addition & 3 deletions xopt/generators/bayesian/expected_improvement.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ def _get_best_f(self, data, objective):
"""get best function value for EI based on the objective"""
if isinstance(objective, CustomXoptObjective):
best_f = objective(
torch.tensor(
self.vocs.observable_data(data).to_numpy(), **self.tkwargs
)
torch.tensor(self.vocs.observable_data(data).to_numpy(), **self.tkwargs)
).max()
else:
# analytic acquisition function for single candidate generation
Expand Down
3 changes: 2 additions & 1 deletion xopt/generators/bayesian/turbo.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def get_trust_region(self, generator) -> Tensor:

# Scale the TR to be proportional to the lengthscales of the objective model
x_center = torch.tensor(
[self.center_x[ele] for ele in self.vocs.variable_names], **generator.tkwargs
[self.center_x[ele] for ele in self.vocs.variable_names],
**generator.tkwargs,
).unsqueeze(dim=0)

# default weights are 1 (if there is no model or a model without
Expand Down
8 changes: 6 additions & 2 deletions xopt/tests/generators/bayesian/test_turbo.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,12 @@ def test_serialization(self):
evaluator = Evaluator(function=sin_function)
for name in ["optimize", "safety"]:
generator = UpperConfidenceBoundGenerator(vocs=vocs, turbo_controller=name)
X = Xopt(evaluator=evaluator, generator=generator, vocs=vocs,
dump_file="dump.yml")
X = Xopt(
evaluator=evaluator,
generator=generator,
vocs=vocs,
dump_file="dump.yml",
)

yaml_str = X.yaml()
X2 = Xopt.from_yaml(yaml_str)
Expand Down

0 comments on commit 2275bd1

Please sign in to comment.