Skip to content

Commit a2714e0

Browse files
committed
lint: flake8 line lengths and other package level issues
1 parent 5d8e0b9 commit a2714e0

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

botorch/acquisition/analytic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ def _log_ei_helper(u: Tensor) -> Tensor:
982982
if not (u.dtype == torch.float32 or u.dtype == torch.float64):
983983
raise TypeError(
984984
f"LogExpectedImprovement only supports torch.float32 and torch.float64 "
985-
f"dtypes, but received {u.dtype = }."
985+
f"dtypes, but received {u.dtype=}."
986986
)
987987
# The function has two branching decisions. The first is u < bound, and in this
988988
# case, just taking the logarithm of the naive _ei_helper implementation works.

botorch/acquisition/logei.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def check_tau(tau: FloatOrTensor, name: str) -> FloatOrTensor:
540540
"""Checks the validity of the tau arguments of the functions below, and returns
541541
`tau` if it is valid."""
542542
if isinstance(tau, Tensor) and tau.numel() != 1:
543-
raise ValueError(name + f" is not a scalar: {tau.numel() = }.")
543+
raise ValueError(name + f" is not a scalar: {tau.numel()=}.")
544544
if not (tau > 0):
545-
raise ValueError(name + f" is non-positive: {tau = }.")
545+
raise ValueError(name + f" is non-positive: {tau=}.")
546546
return tau

botorch/acquisition/multi_objective/hypervolume_knowledge_gradient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ def _split_hvkg_fantasy_points(
557557
"""
558558
if n_f * num_pareto > X.size(-2):
559559
raise ValueError(
560-
f"`n_f*num_pareto` ({n_f*num_pareto}) must be less than"
560+
f"`n_f*num_pareto` ({n_f * num_pareto}) must be less than"
561561
f" the `q`-batch dimension of `X` ({X.size(-2)})."
562562
)
563563
split_sizes = [X.size(-2) - n_f * num_pareto, n_f * num_pareto]

botorch/optim/optimize.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ def __post_init__(self) -> None:
122122
):
123123
if len(batch_initial_conditions_shape) == 2:
124124
warnings.warn(
125-
"If using `batch_initial_conditions` together with `raw_samples`, "
126-
"the `batch_initial_conditions` must have 3 dimensions. "
127-
"Defaulting to old behavior of ignoring `raw_samples` by setting "
128-
"it to None.",
125+
"If using `batch_initial_conditions` together with "
126+
"`raw_samples`, the `batch_initial_conditions` must "
127+
"have 3 dimensions. Defaulting to old behavior of ignoring "
128+
"`raw_samples` by setting it to None.",
129129
RuntimeWarning,
130130
)
131131
# Use object.__setattr__ to bypass immutability and set a value
@@ -137,11 +137,11 @@ def __post_init__(self) -> None:
137137
and batch_initial_conditions_shape[0] not in [1, self.num_restarts]
138138
):
139139
warnings.warn(
140-
"If using `batch_initial_conditions` together with `raw_samples`, "
141-
"the first repeat dimension of `batch_initial_conditions` must "
142-
"match `num_restarts` or be 1 to allow repeat matching. "
143-
"Defaulting to old behavior of ignoring `raw_samples` by setting "
144-
"it to None.",
140+
"If using `batch_initial_conditions` together with "
141+
"`raw_samples`, the first repeat dimension of "
142+
"`batch_initial_conditions` must match `num_restarts` "
143+
"or be 1 to allow repeat matching. Defaulting to old "
144+
"behavior of ignoring `raw_samples` by setting it to None.",
145145
RuntimeWarning,
146146
)
147147
# Use object.__setattr__ to bypass immutability and set a value
@@ -280,7 +280,7 @@ def _optimize_acqf_sequential_q(
280280
if base_X_pending is not None
281281
else candidates
282282
)
283-
logger.info(f"Generated sequential candidate {i+1} of {opt_inputs.q}")
283+
logger.info(f"Generated sequential candidate {i + 1} of {opt_inputs.q}")
284284
opt_inputs.acq_function.set_X_pending(base_X_pending)
285285
return candidates, torch.stack(acq_value_list)
286286

@@ -332,7 +332,8 @@ def _optimize_acqf_batch(opt_inputs: OptimizeAcqfInputs) -> tuple[Tensor, Tensor
332332
required_raw_samples -= opt_inputs.batch_initial_conditions.shape[-2]
333333

334334
if required_raw_samples > 0:
335-
# pyre-ignore[28]: Unexpected keyword argument `acq_function` to anonymous call.
335+
# pyre-ignore[28]: Unexpected keyword argument `acq_function`
336+
# to anonymous call.
336337
generated_initial_conditions = opt_inputs.get_ic_generator()(
337338
acq_function=opt_inputs.acq_function,
338339
bounds=opt_inputs.bounds,
@@ -402,7 +403,7 @@ def _optimize_batch_candidates() -> tuple[Tensor, Tensor, list[Warning]]:
402403
opt_warnings += ws
403404
batch_candidates_list.append(batch_candidates_curr)
404405
batch_acq_values_list.append(batch_acq_values_curr)
405-
logger.info(f"Generated candidate batch {i+1} of {len(batched_ics)}.")
406+
logger.info(f"Generated candidate batch {i + 1} of {len(batched_ics)}.")
406407

407408
batch_candidates = torch.cat(batch_candidates_list)
408409
has_scalars = batch_acq_values_list[0].ndim == 0

botorch/utils/probability/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def log_ndtr(x: Tensor) -> Tensor:
161161
if not (x.dtype == torch.float32 or x.dtype == torch.float64):
162162
raise TypeError(
163163
f"log_Phi only supports torch.float32 and torch.float64 "
164-
f"dtypes, but received {x.dtype = }."
164+
f"dtypes, but received {x.dtype=}."
165165
)
166166
neg_inv_sqrt_2, log_2 = get_constants_like((_neg_inv_sqrt_2, _log_2), x)
167167
return log_erfc(neg_inv_sqrt_2 * x) - log_2
@@ -181,7 +181,7 @@ def log_erfc(x: Tensor) -> Tensor:
181181
if not (x.dtype == torch.float32 or x.dtype == torch.float64):
182182
raise TypeError(
183183
f"log_erfc only supports torch.float32 and torch.float64 "
184-
f"dtypes, but received {x.dtype = }."
184+
f"dtypes, but received {x.dtype=}."
185185
)
186186
is_pos = x > 0
187187
x_pos = x.masked_fill(~is_pos, 0)

test/acquisition/multi_objective/test_hypervolume_knowledge_gradient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def test_split_hvkg_fantasy_points(self):
436436
n_f = 100
437437
num_pareto = 3
438438
msg = (
439-
rf".*\({n_f*num_pareto}\) must be less than"
439+
rf".*\({n_f * num_pareto}\) must be less than"
440440
rf" the `q`-batch dimension of `X` \({X.size(-2)}\)\."
441441
)
442442
with self.assertRaisesRegex(ValueError, msg):

test/optim/test_optimize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_optimize_acqf_joint(
259259
cnt += 1
260260
self.assertEqual(mock_gen_batch_initial_conditions.call_count, cnt)
261261

262-
# test generation with provided initial conditions larger than raw_samples
262+
# test case where provided initial conditions larger than raw_samples
263263
candidates, acq_vals = optimize_acqf(
264264
acq_function=mock_acq_function,
265265
bounds=bounds,

0 commit comments

Comments
 (0)