From 2275bd12f612a9e7aa9981f25d019a1a46401371 Mon Sep 17 00:00:00 2001 From: Ryan Roussel Date: Mon, 4 Nov 2024 11:55:55 -0600 Subject: [PATCH] formatting --- xopt/generators/bayesian/expected_improvement.py | 4 +--- xopt/generators/bayesian/turbo.py | 3 ++- xopt/tests/generators/bayesian/test_turbo.py | 8 ++++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/xopt/generators/bayesian/expected_improvement.py b/xopt/generators/bayesian/expected_improvement.py index 8dba3c06..8c179b4a 100644 --- a/xopt/generators/bayesian/expected_improvement.py +++ b/xopt/generators/bayesian/expected_improvement.py @@ -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 diff --git a/xopt/generators/bayesian/turbo.py b/xopt/generators/bayesian/turbo.py index 8c71079f..27cc7545 100644 --- a/xopt/generators/bayesian/turbo.py +++ b/xopt/generators/bayesian/turbo.py @@ -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 diff --git a/xopt/tests/generators/bayesian/test_turbo.py b/xopt/tests/generators/bayesian/test_turbo.py index 4a108d70..0612ad79 100644 --- a/xopt/tests/generators/bayesian/test_turbo.py +++ b/xopt/tests/generators/bayesian/test_turbo.py @@ -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)