From 491689077bd829b74ad910408a27e98494a4a28c Mon Sep 17 00:00:00 2001 From: Bowie Chen <543091+bowiechen@users.noreply.github.com> Date: Fri, 21 Nov 2025 22:02:53 -0800 Subject: [PATCH] Update pyfmt component on FBS:master (#3088) Summary: X-link: https://github.com/meta-pytorch/tritonbench/pull/661 X-link: https://github.com/facebook/Ax/pull/4572 X-link: https://github.com/facebookexternal/aepsych_prerelease/pull/42 X-link: https://github.com/facebook/dotslash/pull/89 X-link: https://github.com/meta-pytorch/torchx/pull/1165 X-link: https://github.com/facebookresearch/aepsych/pull/824 Pull Request resolved: https://github.com/meta-pytorch/botorch/pull/3088 Differential Revision: D87671961 --- .pre-commit-config.yaml | 8 +- botorch/acquisition/analytic.py | 1 - botorch/acquisition/decoupled.py | 1 - botorch/acquisition/fixed_feature.py | 1 - botorch/acquisition/joint_entropy_search.py | 1 - botorch/acquisition/knowledge_gradient.py | 1 - .../acquisition/max_value_entropy_search.py | 1 - .../hypervolume_knowledge_gradient.py | 1 - botorch/acquisition/prior_guided.py | 1 - botorch/generation/sampling.py | 1 - botorch/models/gp_regression_fidelity.py | 1 - botorch/models/gp_regression_mixed.py | 1 - botorch/models/higher_order_gp.py | 2 +- .../kernels/orthogonal_additive_kernel.py | 1 - botorch/models/latent_kronecker_gp.py | 1 - botorch/models/model_list_gp_regression.py | 1 - botorch/models/relevance_pursuit.py | 1 - .../models/robust_relevance_pursuit_model.py | 1 - botorch/models/transforms/outcome.py | 3 +- .../models/utils/inducing_point_allocators.py | 1 - botorch/optim/batched_lbfgs_b.py | 13 ++- botorch/optim/closures/core.py | 2 - botorch/optim/core.py | 1 - botorch/optim/fit.py | 1 - botorch/optim/optimize_homotopy.py | 3 - botorch/optim/optimize_mixed.py | 3 +- botorch/optim/utils/acquisition_utils.py | 2 +- botorch/optim/utils/common.py | 1 - botorch/optim/utils/model_utils.py | 1 - botorch/posteriors/fully_bayesian.py | 1 - .../sampling/pathwise/features/generators.py | 1 - botorch/sampling/pathwise/prior_samplers.py | 1 - .../sampling/pathwise/update_strategies.py | 3 - botorch/test_functions/utils.py | 1 - botorch/test_utils/mock.py | 1 - botorch/utils/constants.py | 1 - botorch/utils/constraints.py | 3 - botorch/utils/containers.py | 2 - botorch/utils/context_managers.py | 1 - botorch/utils/datasets.py | 7 +- botorch/utils/dispatcher.py | 1 - botorch/utils/low_rank.py | 1 - botorch/utils/multi_objective/hypervolume.py | 2 - botorch/utils/multi_objective/optimize.py | 1 - botorch/utils/probability/linalg.py | 1 - .../utils/probability/unified_skew_normal.py | 1 - botorch/utils/probability/utils.py | 1 - botorch/utils/sampling.py | 4 - .../acquisition/augmented_multisource.py | 1 - .../acquisition/bayesian_active_learning.py | 3 +- .../acquisition/bll_thompson_sampling.py | 3 - botorch_community/acquisition/discretized.py | 1 - .../acquisition/input_constructors.py | 3 - .../models/gp_regression_multisource.py | 1 - botorch_community/models/vbll_helper.py | 1 - botorch_community/models/vblls.py | 1 - botorch_community/posteriors/bll_posterior.py | 1 - requirements-fmt.txt | 8 +- .../test_hypervolume_knowledge_gradient.py | 83 +++++++++++-------- .../test_joint_entropy_search.py | 1 - test/acquisition/test_active_learning.py | 7 +- test/acquisition/test_cached_cholesky.py | 14 ++-- test/acquisition/test_cost_aware.py | 5 +- test/acquisition/test_input_constructors.py | 6 +- test/acquisition/test_logei.py | 1 - test/acquisition/test_objective.py | 1 - test/acquisition/test_thompson_sampling.py | 1 - test/acquisition/test_utils.py | 2 +- test/exceptions/test_errors.py | 1 - test/generation/test_gen.py | 35 ++++---- test/generation/test_utils.py | 1 - test/models/kernels/test_contextual.py | 1 - test/models/test_deterministic.py | 1 - test/models/test_fully_bayesian.py | 1 - test/models/test_fully_bayesian_multitask.py | 1 - test/models/test_gpytorch.py | 1 - test/models/test_map_saas.py | 7 +- test/models/test_model.py | 8 +- test/models/test_relevance_pursuit.py | 3 - test/models/utils/test_assorted.py | 8 +- .../utils/test_inducing_point_allocators.py | 1 - test/optim/test_batched_lbfgs_b.py | 1 - test/optim/test_fit.py | 7 +- test/optim/test_initializers.py | 82 ++++++++++-------- test/optim/test_optimize_mixed.py | 9 +- .../pathwise/features/test_generators.py | 11 ++- .../pathwise/test_posterior_samplers.py | 1 - .../pathwise/test_update_strategies.py | 11 ++- test/sampling/pathwise/test_utils.py | 5 +- test/sampling/test_list_sampler.py | 9 +- test/test_logging.py | 1 - .../test_box_decomposition.py | 26 +++--- test/utils/probability/test_bvn.py | 1 - test/utils/probability/test_lin_ess.py | 2 - test/utils/probability/test_mvnxpb.py | 26 +++--- .../test_truncated_multivariate_normal.py | 1 - .../probability/test_unified_skew_normal.py | 3 - test/utils/probability/test_utils.py | 1 - test/utils/test_safe_math.py | 1 - test/utils/test_test_helpers.py | 1 - .../models/test_gp_regression_multisource.py | 1 - test_community/models/test_vbll_helper.py | 1 - test_community/models/test_vblls.py | 1 - test_community/posteriors/test_bll.py | 1 - 104 files changed, 229 insertions(+), 278 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4b15c5da4e..a1e3fe6bd1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,13 +11,13 @@ repos: - PyYAML - repo: https://github.com/omnilib/ufmt - rev: v2.8.0 + rev: v2.9.0 hooks: - id: ufmt additional_dependencies: - - black==24.4.2 - - usort==1.0.8.post1 - - ruff-api==0.1.0 + - black==25.11.0 + - usort==1.1.0 + - ruff-api==0.2.0 - stdlibs==2024.1.28 args: [format] diff --git a/botorch/acquisition/analytic.py b/botorch/acquisition/analytic.py index 3ca3809940..0fe3696d10 100644 --- a/botorch/acquisition/analytic.py +++ b/botorch/acquisition/analytic.py @@ -12,7 +12,6 @@ from __future__ import annotations import math - from abc import ABC, abstractmethod from contextlib import nullcontext from copy import deepcopy diff --git a/botorch/acquisition/decoupled.py b/botorch/acquisition/decoupled.py index 8c893b027d..d8a5dd129b 100644 --- a/botorch/acquisition/decoupled.py +++ b/botorch/acquisition/decoupled.py @@ -16,7 +16,6 @@ from botorch.exceptions import BotorchWarning from botorch.exceptions.errors import BotorchTensorDimensionError from botorch.logging import shape_to_str - from botorch.models.model import ModelList from torch import Tensor diff --git a/botorch/acquisition/fixed_feature.py b/botorch/acquisition/fixed_feature.py index a7c2b1766e..91973e3ba2 100644 --- a/botorch/acquisition/fixed_feature.py +++ b/botorch/acquisition/fixed_feature.py @@ -12,7 +12,6 @@ from __future__ import annotations from collections.abc import Sequence - from numbers import Number import torch diff --git a/botorch/acquisition/joint_entropy_search.py b/botorch/acquisition/joint_entropy_search.py index ea648451a7..70dbb329db 100644 --- a/botorch/acquisition/joint_entropy_search.py +++ b/botorch/acquisition/joint_entropy_search.py @@ -40,7 +40,6 @@ t_batch_mode_transform, ) from torch import Tensor - from torch.distributions import Normal MCMC_DIM = -3 # Only relevant if you do Fully Bayesian GPs. diff --git a/botorch/acquisition/knowledge_gradient.py b/botorch/acquisition/knowledge_gradient.py index d96eea7ee9..2c3c58de6f 100644 --- a/botorch/acquisition/knowledge_gradient.py +++ b/botorch/acquisition/knowledge_gradient.py @@ -27,7 +27,6 @@ from __future__ import annotations from collections.abc import Callable - from copy import deepcopy from typing import Any diff --git a/botorch/acquisition/max_value_entropy_search.py b/botorch/acquisition/max_value_entropy_search.py index 9f4d08ee91..1e87bb6bd7 100644 --- a/botorch/acquisition/max_value_entropy_search.py +++ b/botorch/acquisition/max_value_entropy_search.py @@ -50,7 +50,6 @@ match_batch_shape, t_batch_mode_transform, ) - from linear_operator.functions import inv_quad from linear_operator.utils.cholesky import psd_safe_cholesky from scipy.optimize import brentq diff --git a/botorch/acquisition/multi_objective/hypervolume_knowledge_gradient.py b/botorch/acquisition/multi_objective/hypervolume_knowledge_gradient.py index f1301028c3..ac2fa18e5e 100644 --- a/botorch/acquisition/multi_objective/hypervolume_knowledge_gradient.py +++ b/botorch/acquisition/multi_objective/hypervolume_knowledge_gradient.py @@ -27,7 +27,6 @@ AcquisitionFunction, OneShotAcquisitionFunction, ) - from botorch.acquisition.cost_aware import CostAwareUtility from botorch.acquisition.decoupled import DecoupledAcquisitionFunction from botorch.acquisition.knowledge_gradient import ProjectedAcquisitionFunction diff --git a/botorch/acquisition/prior_guided.py b/botorch/acquisition/prior_guided.py index 07d8b04735..250cf48533 100644 --- a/botorch/acquisition/prior_guided.py +++ b/botorch/acquisition/prior_guided.py @@ -27,7 +27,6 @@ t_batch_mode_transform, ) from torch import Tensor - from torch.nn import Module diff --git a/botorch/generation/sampling.py b/botorch/generation/sampling.py index 7842e95780..3c68862e05 100644 --- a/botorch/generation/sampling.py +++ b/botorch/generation/sampling.py @@ -27,7 +27,6 @@ ) from botorch.generation.utils import _flip_sub_unique from botorch.models.model import Model - from botorch.models.model_list_gp_regression import ModelListGP from botorch.models.multitask import MultiTaskGP from botorch.utils.sampling import batched_multinomial diff --git a/botorch/models/gp_regression_fidelity.py b/botorch/models/gp_regression_fidelity.py index cc583a7953..f860248864 100644 --- a/botorch/models/gp_regression_fidelity.py +++ b/botorch/models/gp_regression_fidelity.py @@ -26,7 +26,6 @@ from __future__ import annotations from collections.abc import Sequence - from typing import Any import torch diff --git a/botorch/models/gp_regression_mixed.py b/botorch/models/gp_regression_mixed.py index a926c2184b..9d1855e3c6 100644 --- a/botorch/models/gp_regression_mixed.py +++ b/botorch/models/gp_regression_mixed.py @@ -7,7 +7,6 @@ from __future__ import annotations from collections.abc import Callable - from typing import Any import torch diff --git a/botorch/models/higher_order_gp.py b/botorch/models/higher_order_gp.py index 260ea19354..1d9679197f 100644 --- a/botorch/models/higher_order_gp.py +++ b/botorch/models/higher_order_gp.py @@ -230,7 +230,7 @@ def __init__( warnings.warn( "HigherOrderGP does not support the outcome_transform " "`Standardize`! Using `FlattenedStandardize` with `output_shape=" - f"{train_Y.shape[- num_output_dims:]} and batch_shape=" + f"{train_Y.shape[-num_output_dims:]} and batch_shape=" f"{batch_shape} instead.", RuntimeWarning, stacklevel=2, diff --git a/botorch/models/kernels/orthogonal_additive_kernel.py b/botorch/models/kernels/orthogonal_additive_kernel.py index ad7e9525fe..0a8c8819ae 100644 --- a/botorch/models/kernels/orthogonal_additive_kernel.py +++ b/botorch/models/kernels/orthogonal_additive_kernel.py @@ -12,7 +12,6 @@ from gpytorch.kernels import Kernel from gpytorch.module import Module from gpytorch.priors import Prior - from torch import nn, Tensor _positivity_constraint = Positive() diff --git a/botorch/models/latent_kronecker_gp.py b/botorch/models/latent_kronecker_gp.py index ee99f1c2a3..c8cd6ff61c 100644 --- a/botorch/models/latent_kronecker_gp.py +++ b/botorch/models/latent_kronecker_gp.py @@ -44,7 +44,6 @@ from gpytorch.likelihoods import GaussianLikelihood from gpytorch.likelihoods.likelihood import Likelihood from gpytorch.means import Mean, ZeroMean - from gpytorch.models.exact_gp import ExactGP from gpytorch.module import Module from linear_operator import settings diff --git a/botorch/models/model_list_gp_regression.py b/botorch/models/model_list_gp_regression.py index e446508b28..27add3b7a3 100644 --- a/botorch/models/model_list_gp_regression.py +++ b/botorch/models/model_list_gp_regression.py @@ -13,7 +13,6 @@ from typing import Any import torch - from botorch.exceptions.errors import BotorchTensorDimensionError from botorch.models.gpytorch import GPyTorchModel, ModelListGPyTorchModel from botorch.models.model import FantasizeMixin diff --git a/botorch/models/relevance_pursuit.py b/botorch/models/relevance_pursuit.py index 129071aa42..11bcf592b1 100644 --- a/botorch/models/relevance_pursuit.py +++ b/botorch/models/relevance_pursuit.py @@ -18,7 +18,6 @@ from __future__ import annotations import math - from abc import ABC, abstractmethod from collections.abc import Callable, Sequence from copy import copy, deepcopy diff --git a/botorch/models/robust_relevance_pursuit_model.py b/botorch/models/robust_relevance_pursuit_model.py index a58b8cd242..9e681aab9b 100644 --- a/botorch/models/robust_relevance_pursuit_model.py +++ b/botorch/models/robust_relevance_pursuit_model.py @@ -31,7 +31,6 @@ from __future__ import annotations from abc import ABC, abstractmethod - from typing import Any, Callable, Mapping, Optional, Sequence import torch diff --git a/botorch/models/transforms/outcome.py b/botorch/models/transforms/outcome.py index f9165199c3..338fa7e879 100644 --- a/botorch/models/transforms/outcome.py +++ b/botorch/models/transforms/outcome.py @@ -75,8 +75,7 @@ def subset_output(self, idcs: list[int]) -> OutcomeTransform: The current outcome transform, subset to the specified output indices. """ raise NotImplementedError( - f"{self.__class__.__name__} does not implement the " - "`subset_output` method" + f"{self.__class__.__name__} does not implement the `subset_output` method" ) def untransform( diff --git a/botorch/models/utils/inducing_point_allocators.py b/botorch/models/utils/inducing_point_allocators.py index 27b49ebc25..6ee7d640fc 100644 --- a/botorch/models/utils/inducing_point_allocators.py +++ b/botorch/models/utils/inducing_point_allocators.py @@ -25,7 +25,6 @@ import torch from botorch.exceptions.errors import UnsupportedError from botorch.models.model import Model - from botorch.utils.probability.utils import ndtr as Phi, phi from gpytorch.module import Module from linear_operator.operators import LinearOperator diff --git a/botorch/optim/batched_lbfgs_b.py b/botorch/optim/batched_lbfgs_b.py index b52ba3a7fc..d61d471602 100644 --- a/botorch/optim/batched_lbfgs_b.py +++ b/botorch/optim/batched_lbfgs_b.py @@ -45,7 +45,6 @@ import typing as tp import numpy as np - from numpy import array, asarray, zeros from scipy.optimize import _lbfgsb from scipy.optimize._constraints import old_bound_to_new @@ -339,9 +338,9 @@ def fmin_l_bfgs_b_batched( if ftol is None: ftol = factr * np.finfo(float).eps else: - assert ( - factr is None - ), "ftol and factr cannot be used together, set factr explicitly to None." + assert factr is None, ( + "ftol and factr cannot be used together, set factr explicitly to None." + ) # build options callback = _wrap_callback(callback) @@ -672,7 +671,7 @@ def translate_bounds_for_lbfgsb( bounds[i] = list(bounds[i]) if len(bounds[i]) == num_features: bounds[i] = sum([bounds[i] for _ in range(q)], []) - assert ( - len(bounds[i]) == num_features * q - ), f"Instead got {len(bounds[i])} != {num_features} * {q}." + assert len(bounds[i]) == num_features * q, ( + f"Instead got {len(bounds[i])} != {num_features} * {q}." + ) return list(zip(*bounds)) diff --git a/botorch/optim/closures/core.py b/botorch/optim/closures/core.py index 455266ad70..cf923cf869 100644 --- a/botorch/optim/closures/core.py +++ b/botorch/optim/closures/core.py @@ -9,13 +9,11 @@ from __future__ import annotations from collections.abc import Callable, Sequence - from typing import Any import numpy as np import numpy.typing as npt import torch - from botorch.optim.utils import _handle_numerical_errors from botorch.optim.utils.numpy_utils import as_ndarray from botorch.utils.context_managers import zero_grad_ctx diff --git a/botorch/optim/core.py b/botorch/optim/core.py index 7d63130f77..427c3aca94 100644 --- a/botorch/optim/core.py +++ b/botorch/optim/core.py @@ -18,7 +18,6 @@ from typing import Any import numpy.typing as npt - from botorch.optim.closures import NdarrayOptimizationClosure from botorch.optim.stopping import StoppingCriterion from botorch.optim.utils.numpy_utils import get_bounds_as_ndarray diff --git a/botorch/optim/fit.py b/botorch/optim/fit.py index cda6cd1aa3..fd2b382319 100644 --- a/botorch/optim/fit.py +++ b/botorch/optim/fit.py @@ -9,7 +9,6 @@ from __future__ import annotations from collections.abc import Callable, Sequence - from functools import partial from typing import Any, Optional from warnings import warn diff --git a/botorch/optim/optimize_homotopy.py b/botorch/optim/optimize_homotopy.py index 00a38ab425..e600543dc2 100644 --- a/botorch/optim/optimize_homotopy.py +++ b/botorch/optim/optimize_homotopy.py @@ -6,14 +6,11 @@ from __future__ import annotations import warnings - from collections.abc import Callable - from typing import Any import torch from botorch.acquisition import AcquisitionFunction - from botorch.generation.gen import TGenCandidates from botorch.optim.homotopy import Homotopy from botorch.optim.initializers import TGenInitialConditions diff --git a/botorch/optim/optimize_mixed.py b/botorch/optim/optimize_mixed.py index 2d2f7c351b..d03104cc28 100644 --- a/botorch/optim/optimize_mixed.py +++ b/botorch/optim/optimize_mixed.py @@ -929,8 +929,7 @@ def optimize_acqf_mixed_alternating( if sequential is False: # pragma: no cover raise NotImplementedError( - "`optimize_acqf_mixed_alternating` only supports " - "sequential optimization." + "`optimize_acqf_mixed_alternating` only supports sequential optimization." ) cat_dims = cat_dims or {} diff --git a/botorch/optim/utils/acquisition_utils.py b/botorch/optim/utils/acquisition_utils.py index a0409b50fb..6896fe9b49 100644 --- a/botorch/optim/utils/acquisition_utils.py +++ b/botorch/optim/utils/acquisition_utils.py @@ -59,7 +59,7 @@ def columnwise_clamp( out = X.clamp(lower, upper) if raise_on_violation and not X.allclose(out): raise BotorchError( - "Original value(s) are out of bounds: " f"{out=}, {X=}, {lower=}, {upper=}." + f"Original value(s) are out of bounds: {out=}, {X=}, {lower=}, {upper=}." ) return out diff --git a/botorch/optim/utils/common.py b/botorch/optim/utils/common.py index f5440c4d22..31721bdf63 100644 --- a/botorch/optim/utils/common.py +++ b/botorch/optim/utils/common.py @@ -9,7 +9,6 @@ from __future__ import annotations from collections.abc import Callable - from logging import debug as logging_debug from warnings import warn_explicit, WarningMessage diff --git a/botorch/optim/utils/model_utils.py b/botorch/optim/utils/model_utils.py index f2ad418468..bf17a5ae01 100644 --- a/botorch/optim/utils/model_utils.py +++ b/botorch/optim/utils/model_utils.py @@ -9,7 +9,6 @@ from __future__ import annotations from collections.abc import Callable, Iterator - from re import Pattern from typing import Any, NamedTuple from warnings import warn diff --git a/botorch/posteriors/fully_bayesian.py b/botorch/posteriors/fully_bayesian.py index c47882adb0..913b1f8777 100644 --- a/botorch/posteriors/fully_bayesian.py +++ b/botorch/posteriors/fully_bayesian.py @@ -6,7 +6,6 @@ from __future__ import annotations from collections.abc import Callable - from warnings import warn import torch diff --git a/botorch/sampling/pathwise/features/generators.py b/botorch/sampling/pathwise/features/generators.py index 6cdc1ee9d6..560e661863 100644 --- a/botorch/sampling/pathwise/features/generators.py +++ b/botorch/sampling/pathwise/features/generators.py @@ -17,7 +17,6 @@ from __future__ import annotations from collections.abc import Callable - from typing import Any import torch diff --git a/botorch/sampling/pathwise/prior_samplers.py b/botorch/sampling/pathwise/prior_samplers.py index 37e152567c..a417956f26 100644 --- a/botorch/sampling/pathwise/prior_samplers.py +++ b/botorch/sampling/pathwise/prior_samplers.py @@ -7,7 +7,6 @@ from __future__ import annotations from collections.abc import Callable - from typing import Any from botorch.models.approximate_gp import ApproximateGPyTorchModel diff --git a/botorch/sampling/pathwise/update_strategies.py b/botorch/sampling/pathwise/update_strategies.py index f78cb5535f..e5159a0a6a 100644 --- a/botorch/sampling/pathwise/update_strategies.py +++ b/botorch/sampling/pathwise/update_strategies.py @@ -7,13 +7,10 @@ from __future__ import annotations from collections.abc import Callable - from types import NoneType - from typing import Any import torch - from botorch.models.approximate_gp import ApproximateGPyTorchModel from botorch.models.transforms.input import InputTransform from botorch.sampling.pathwise.features import KernelEvaluationMap diff --git a/botorch/test_functions/utils.py b/botorch/test_functions/utils.py index 18025dda49..5f0d26c3e9 100644 --- a/botorch/test_functions/utils.py +++ b/botorch/test_functions/utils.py @@ -8,7 +8,6 @@ from __future__ import annotations import torch - from torch import Tensor diff --git a/botorch/test_utils/mock.py b/botorch/test_utils/mock.py index da5f7bea31..114eed9533 100644 --- a/botorch/test_utils/mock.py +++ b/botorch/test_utils/mock.py @@ -18,7 +18,6 @@ from unittest import mock from botorch.optim.batched_lbfgs_b import fmin_l_bfgs_b_batched - from botorch.optim.initializers import ( gen_batch_initial_conditions, gen_one_shot_kg_initial_conditions, diff --git a/botorch/utils/constants.py b/botorch/utils/constants.py index eb09e6ce4c..579b6eca13 100644 --- a/botorch/utils/constants.py +++ b/botorch/utils/constants.py @@ -7,7 +7,6 @@ from __future__ import annotations from collections.abc import Iterator - from functools import lru_cache from numbers import Number diff --git a/botorch/utils/constraints.py b/botorch/utils/constraints.py index 72ba696932..082dfa102b 100644 --- a/botorch/utils/constraints.py +++ b/botorch/utils/constraints.py @@ -11,15 +11,12 @@ from __future__ import annotations import math - from collections.abc import Callable - from functools import partial import torch from gpytorch import settings from gpytorch.constraints import Interval - from torch import Tensor diff --git a/botorch/utils/containers.py b/botorch/utils/containers.py index 8cd2aabe76..98d7883fc6 100644 --- a/botorch/utils/containers.py +++ b/botorch/utils/containers.py @@ -9,13 +9,11 @@ from __future__ import annotations import dataclasses - from abc import ABC, abstractmethod from dataclasses import dataclass, fields from typing import Any import torch - from torch import device as Device, dtype as Dtype, LongTensor, Size, Tensor diff --git a/botorch/utils/context_managers.py b/botorch/utils/context_managers.py index d399658258..e38cf85376 100644 --- a/botorch/utils/context_managers.py +++ b/botorch/utils/context_managers.py @@ -11,7 +11,6 @@ from __future__ import annotations from collections.abc import Callable, Generator, Iterable - from contextlib import contextmanager from typing import Any, NamedTuple diff --git a/botorch/utils/datasets.py b/botorch/utils/datasets.py index 9bc7663fef..8177442d99 100644 --- a/botorch/utils/datasets.py +++ b/botorch/utils/datasets.py @@ -9,7 +9,6 @@ from __future__ import annotations import copy - from typing import Any import torch @@ -661,9 +660,9 @@ def _extract_context_buckets(self) -> list[str]: buckets are taken from the parameter decomposition. """ if len(self.outcome_names) > 1: - assert len(self.outcome_names) == len( - self.metric_decomposition - ), "Expected a single dataset, or one for each context bucket." + assert len(self.outcome_names) == len(self.metric_decomposition), ( + "Expected a single dataset, or one for each context bucket." + ) context_buckets = [] for outcome_name in self.outcome_names: for k, v in self.metric_decomposition.items(): diff --git a/botorch/utils/dispatcher.py b/botorch/utils/dispatcher.py index 5995c54ba7..01cfa3c849 100644 --- a/botorch/utils/dispatcher.py +++ b/botorch/utils/dispatcher.py @@ -7,7 +7,6 @@ from __future__ import annotations from collections.abc import Callable - from inspect import getsource, getsourcefile from typing import Any diff --git a/botorch/utils/low_rank.py b/botorch/utils/low_rank.py index 1476ca8bfe..4489500f83 100644 --- a/botorch/utils/low_rank.py +++ b/botorch/utils/low_rank.py @@ -14,7 +14,6 @@ MultitaskMultivariateNormal, ) from linear_operator.operators import BlockDiagLinearOperator, LinearOperator - from linear_operator.utils.cholesky import psd_safe_cholesky from linear_operator.utils.errors import NanError from torch import Tensor diff --git a/botorch/utils/multi_objective/hypervolume.py b/botorch/utils/multi_objective/hypervolume.py index 9a160f6811..ea2d0dde34 100644 --- a/botorch/utils/multi_objective/hypervolume.py +++ b/botorch/utils/multi_objective/hypervolume.py @@ -22,11 +22,9 @@ from __future__ import annotations import random - import warnings from collections.abc import Callable from copy import deepcopy - from itertools import combinations import torch diff --git a/botorch/utils/multi_objective/optimize.py b/botorch/utils/multi_objective/optimize.py index 26a23a414a..4a029c31c2 100644 --- a/botorch/utils/multi_objective/optimize.py +++ b/botorch/utils/multi_objective/optimize.py @@ -7,7 +7,6 @@ from __future__ import annotations import warnings - from typing import Callable import numpy as np diff --git a/botorch/utils/probability/linalg.py b/botorch/utils/probability/linalg.py index 88434ef8c4..887f0f9c34 100644 --- a/botorch/utils/probability/linalg.py +++ b/botorch/utils/probability/linalg.py @@ -7,7 +7,6 @@ from __future__ import annotations from collections.abc import Sequence - from dataclasses import dataclass, InitVar from itertools import chain from typing import Any diff --git a/botorch/utils/probability/unified_skew_normal.py b/botorch/utils/probability/unified_skew_normal.py index d13715f424..2445165f2b 100644 --- a/botorch/utils/probability/unified_skew_normal.py +++ b/botorch/utils/probability/unified_skew_normal.py @@ -7,7 +7,6 @@ from __future__ import annotations from collections.abc import Sequence - from inspect import getmembers import torch diff --git a/botorch/utils/probability/utils.py b/botorch/utils/probability/utils.py index e469067d24..ca751d0e15 100644 --- a/botorch/utils/probability/utils.py +++ b/botorch/utils/probability/utils.py @@ -8,7 +8,6 @@ import math from collections.abc import Callable, Iterable, Iterator - from functools import lru_cache from math import pi from numbers import Number diff --git a/botorch/utils/sampling.py b/botorch/utils/sampling.py index 31814a0aae..8cc785810d 100644 --- a/botorch/utils/sampling.py +++ b/botorch/utils/sampling.py @@ -17,7 +17,6 @@ from __future__ import annotations import warnings - from abc import ABC, abstractmethod from collections.abc import Callable, Generator, Iterable from contextlib import contextmanager @@ -27,9 +26,7 @@ import numpy as np import numpy.typing as npt import scipy - import torch - from botorch.exceptions.errors import ( BotorchError, BotorchTensorDimensionError, @@ -37,7 +34,6 @@ ) from botorch.exceptions.warnings import UserInputWarning from botorch.sampling.qmc import NormalQMCEngine - from botorch.utils.transforms import normalize, standardize, unnormalize from scipy.spatial import Delaunay, HalfspaceIntersection from torch import LongTensor, Tensor diff --git a/botorch_community/acquisition/augmented_multisource.py b/botorch_community/acquisition/augmented_multisource.py index 69342dabcb..9d839eb03f 100644 --- a/botorch_community/acquisition/augmented_multisource.py +++ b/botorch_community/acquisition/augmented_multisource.py @@ -23,7 +23,6 @@ from typing import Dict, Optional, Tuple, Union import torch - from botorch.acquisition import UpperConfidenceBound from botorch.acquisition.objective import PosteriorTransform from botorch.exceptions import UnsupportedError diff --git a/botorch_community/acquisition/bayesian_active_learning.py b/botorch_community/acquisition/bayesian_active_learning.py index 14df4c7193..8f57446372 100644 --- a/botorch_community/acquisition/bayesian_active_learning.py +++ b/botorch_community/acquisition/bayesian_active_learning.py @@ -45,7 +45,6 @@ concatenate_pending_points, t_batch_mode_transform, ) - from botorch_community.utils.stat_dist import mvn_hellinger_distance, mvn_kl_divergence from torch import Tensor @@ -139,7 +138,7 @@ def __init__( # the default number of MC samples (512) are too many when doing FB modeling. if distance_metric not in DISTANCE_METRICS.keys(): raise ValueError( - f"Distance metric need to be one of " f"{list(DISTANCE_METRICS.keys())}" + f"Distance metric need to be one of {list(DISTANCE_METRICS.keys())}" ) self.distance = DISTANCE_METRICS[distance_metric] diff --git a/botorch_community/acquisition/bll_thompson_sampling.py b/botorch_community/acquisition/bll_thompson_sampling.py index 8cd9622557..62ad040de9 100644 --- a/botorch_community/acquisition/bll_thompson_sampling.py +++ b/botorch_community/acquisition/bll_thompson_sampling.py @@ -8,11 +8,8 @@ import numpy as np import scipy - import torch - from botorch.logging import logger - from botorch_community.models.blls import AbstractBLLModel from torch.func import grad diff --git a/botorch_community/acquisition/discretized.py b/botorch_community/acquisition/discretized.py index 607d610ce7..c506098308 100644 --- a/botorch_community/acquisition/discretized.py +++ b/botorch_community/acquisition/discretized.py @@ -16,7 +16,6 @@ PosteriorTransform, ScalarizedPosteriorTransform, ) - from botorch.exceptions.errors import UnsupportedError from botorch.models.model import Model from botorch.utils.transforms import ( diff --git a/botorch_community/acquisition/input_constructors.py b/botorch_community/acquisition/input_constructors.py index 2b9b02c7db..03e4daf7a2 100644 --- a/botorch_community/acquisition/input_constructors.py +++ b/botorch_community/acquisition/input_constructors.py @@ -16,7 +16,6 @@ from typing import Any, Hashable, List, Optional, Tuple import torch - from botorch.acquisition.input_constructors import ( acqf_input_constructor, get_best_f_analytic, @@ -27,14 +26,12 @@ ) from botorch.acquisition.utils import get_optimal_samples from botorch.models.model import Model - from botorch.utils.datasets import SupervisedDataset from botorch_community.acquisition.bayesian_active_learning import ( qBayesianQueryByComittee, qBayesianVarianceReduction, qStatisticalDistanceActiveLearning, ) - from botorch_community.acquisition.discretized import ( DiscretizedExpectedImprovement, DiscretizedProbabilityOfImprovement, diff --git a/botorch_community/models/gp_regression_multisource.py b/botorch_community/models/gp_regression_multisource.py index 3af1d49cbc..8162d906fd 100644 --- a/botorch_community/models/gp_regression_multisource.py +++ b/botorch_community/models/gp_regression_multisource.py @@ -24,7 +24,6 @@ from typing import Optional import torch - from botorch import fit_gpytorch_mll from botorch.exceptions import InputDataError from botorch.models import SingleTaskGP diff --git a/botorch_community/models/vbll_helper.py b/botorch_community/models/vbll_helper.py index abba115d35..e73d935ac9 100644 --- a/botorch_community/models/vbll_helper.py +++ b/botorch_community/models/vbll_helper.py @@ -18,7 +18,6 @@ import numpy as np import torch import torch.nn as nn - from botorch.logging import logger from torch import Tensor diff --git a/botorch_community/models/vblls.py b/botorch_community/models/vblls.py index 1921c88629..81157d9b87 100644 --- a/botorch_community/models/vblls.py +++ b/botorch_community/models/vblls.py @@ -21,7 +21,6 @@ import torch import torch.nn as nn - from botorch.logging import logger from botorch.posteriors import Posterior from botorch_community.models.blls import AbstractBLLModel diff --git a/botorch_community/posteriors/bll_posterior.py b/botorch_community/posteriors/bll_posterior.py index ab7d613ca0..81d06f5880 100644 --- a/botorch_community/posteriors/bll_posterior.py +++ b/botorch_community/posteriors/bll_posterior.py @@ -12,7 +12,6 @@ from botorch.posteriors import GPyTorchPosterior from botorch_community.models.blls import AbstractBLLModel from gpytorch.distributions import MultivariateNormal - from torch import Tensor diff --git a/requirements-fmt.txt b/requirements-fmt.txt index 7ef5305e7b..0effe7e4e2 100644 --- a/requirements-fmt.txt +++ b/requirements-fmt.txt @@ -1,6 +1,6 @@ # generated by `pyfmt --requirements` -black==24.4.2 -ruff-api==0.1.0 +black==25.11.0 +ruff-api==0.2.0 stdlibs==2024.1.28 -ufmt==2.8.0 -usort==1.0.8.post1 +ufmt==2.9.0 +usort==1.1.0 diff --git a/test/acquisition/multi_objective/test_hypervolume_knowledge_gradient.py b/test/acquisition/multi_objective/test_hypervolume_knowledge_gradient.py index 8053d258b2..0e9035cab5 100644 --- a/test/acquisition/multi_objective/test_hypervolume_knowledge_gradient.py +++ b/test/acquisition/multi_objective/test_hypervolume_knowledge_gradient.py @@ -9,7 +9,6 @@ from unittest import mock import numpy as np - import torch from botorch.acquisition.cost_aware import ( GenericCostAwareUtility, @@ -197,11 +196,12 @@ def test_evaluate_q_hvkg(self): else: mf_kwargs = {} - with mock.patch.object( - ModelListGP, "fantasize", return_value=mfm - ) as patch_f, mock.patch( - NO, new_callable=mock.PropertyMock - ) as mock_num_outputs: + with ( + mock.patch.object( + ModelListGP, "fantasize", return_value=mfm + ) as patch_f, + mock.patch(NO, new_callable=mock.PropertyMock) as mock_num_outputs, + ): mock_num_outputs.return_value = 2 qHVKG = acqf_class( model=model, @@ -235,11 +235,12 @@ def test_evaluate_q_hvkg(self): variance = torch.rand(n_f, b, num_pareto, 2, **tkwargs) mfm = MockModel(MockPosterior(mean=mean, variance=variance)) X = torch.rand(b, n_f * num_pareto + 1, 1, **tkwargs) - with mock.patch.object( - ModelListGP, "fantasize", return_value=mfm - ) as patch_f, mock.patch( - NO, new_callable=mock.PropertyMock - ) as mock_num_outputs: + with ( + mock.patch.object( + ModelListGP, "fantasize", return_value=mfm + ) as patch_f, + mock.patch(NO, new_callable=mock.PropertyMock) as mock_num_outputs, + ): mock_num_outputs.return_value = 2 qHVKG = acqf_class( model=model, @@ -288,11 +289,12 @@ def test_evaluate_q_hvkg(self): cost_model=GenericDeterministicModel(cost_fn, num_outputs=2), log=log_ehvi, ) - with mock.patch.object( - ModelListGP, "fantasize", return_value=mfm - ) as patch_f, mock.patch( - NO, new_callable=mock.PropertyMock - ) as mock_num_outputs: + with ( + mock.patch.object( + ModelListGP, "fantasize", return_value=mfm + ) as patch_f, + mock.patch(NO, new_callable=mock.PropertyMock) as mock_num_outputs, + ): mock_num_outputs.return_value = 2 qHVKG = acqf_class( model=model, @@ -342,11 +344,12 @@ def test_evaluate_q_hvkg(self): cost_model=GenericDeterministicModel(cost_fn, num_outputs=2), log=False, ) - with mock.patch.object( - ModelListGP, "fantasize", return_value=mfm - ) as patch_f, mock.patch( - NO, new_callable=mock.PropertyMock - ) as mock_num_outputs: + with ( + mock.patch.object( + ModelListGP, "fantasize", return_value=mfm + ) as patch_f, + mock.patch(NO, new_callable=mock.PropertyMock) as mock_num_outputs, + ): mock_num_outputs.return_value = 2 qHVKG = acqf_class( model=model, @@ -371,11 +374,12 @@ def test_evaluate_q_hvkg(self): cost_aware_utility = GenericCostAwareUtility( cost=GenericDeterministicModel(cost_fn, num_outputs=2), ) - with mock.patch.object( - ModelListGP, "fantasize", return_value=mfm - ) as patch_f, mock.patch( - NO, new_callable=mock.PropertyMock - ) as mock_num_outputs: + with ( + mock.patch.object( + ModelListGP, "fantasize", return_value=mfm + ) as patch_f, + mock.patch(NO, new_callable=mock.PropertyMock) as mock_num_outputs, + ): mock_num_outputs.return_value = 2 qHVKG = acqf_class( model=model, @@ -407,11 +411,14 @@ def test_evaluate_q_hvkg(self): "hypervolume_knowledge_gradient._get_hv_value_function", wraps=_get_hv_value_function, ) as mock_get_value_func: - with mock.patch.object( - ModelListGP, "fantasize", return_value=mfm - ) as patch_f, mock.patch( - NO, new_callable=mock.PropertyMock - ) as mock_num_outputs: + with ( + mock.patch.object( + ModelListGP, "fantasize", return_value=mfm + ) as patch_f, + mock.patch( + NO, new_callable=mock.PropertyMock + ) as mock_num_outputs, + ): mock_num_outputs.return_value = 2 qHVKG = acqf_class( model=model, @@ -454,11 +461,15 @@ def test_evaluate_q_hvkg(self): X = torch.rand(n_f * num_pareto + 1, 1, **tkwargs) for use_posterior_mean in (True, False): - with mock.patch.object( - ModelListGP, "fantasize", return_value=mfm - ) as patch_f, mock.patch( - NO, new_callable=mock.PropertyMock - ) as mock_num_outputs, warnings.catch_warnings(record=True) as ws: + with ( + mock.patch.object( + ModelListGP, "fantasize", return_value=mfm + ) as patch_f, + mock.patch( + NO, new_callable=mock.PropertyMock + ) as mock_num_outputs, + warnings.catch_warnings(record=True) as ws, + ): mock_num_outputs.return_value = 3 qHVKG = acqf_class( model=model, diff --git a/test/acquisition/multi_objective/test_joint_entropy_search.py b/test/acquisition/multi_objective/test_joint_entropy_search.py index c50ce25511..e69703c959 100644 --- a/test/acquisition/multi_objective/test_joint_entropy_search.py +++ b/test/acquisition/multi_objective/test_joint_entropy_search.py @@ -12,7 +12,6 @@ qLowerBoundMultiObjectiveJointEntropySearch, ) from botorch.acquisition.multi_objective.utils import compute_sample_box_decomposition - from botorch.exceptions import UnsupportedError from botorch.models.gp_regression import SingleTaskGP from botorch.models.model_list_gp_regression import ModelListGP diff --git a/test/acquisition/test_active_learning.py b/test/acquisition/test_active_learning.py index f7cb7be937..252a045eb9 100644 --- a/test/acquisition/test_active_learning.py +++ b/test/acquisition/test_active_learning.py @@ -85,9 +85,10 @@ def test_q_neg_int_post_variance(self): f_posterior = GPyTorchPosterior(MultitaskMultivariateNormal(mean, cov)) mc_points = torch.rand(10, 1, device=self.device, dtype=dtype) mfm = MockModel(f_posterior) - with mock.patch.object( - MockModel, "fantasize", return_value=mfm - ), mock.patch(no, new_callable=mock.PropertyMock) as mock_num_outputs: + with ( + mock.patch.object(MockModel, "fantasize", return_value=mfm), + mock.patch(no, new_callable=mock.PropertyMock) as mock_num_outputs, + ): mock_num_outputs.return_value = 2 mm = MockModel(None) diff --git a/test/acquisition/test_cached_cholesky.py b/test/acquisition/test_cached_cholesky.py index b260a237ea..a412afd903 100644 --- a/test/acquisition/test_cached_cholesky.py +++ b/test/acquisition/test_cached_cholesky.py @@ -194,12 +194,14 @@ def test_get_f_X_samples(self): base_samples = torch.rand(1, 5, 1, **tkwargs) acqf.sampler.base_samples = base_samples acqf._baseline_L = baseline_L - with mock.patch( - "botorch.acquisition.cached_cholesky.sample_cached_cholesky", - side_effect=error_cls, - ) as mock_sample_cached_cholesky, warnings.catch_warnings( - record=True - ) as ws: + with ( + mock.patch( + "botorch.acquisition.cached_cholesky." + "sample_cached_cholesky", + side_effect=error_cls, + ) as mock_sample_cached_cholesky, + warnings.catch_warnings(record=True) as ws, + ): samples = acqf._get_f_X_samples(posterior=posterior, q_in=q) mock_sample_cached_cholesky.assert_called_once_with( posterior=posterior, diff --git a/test/acquisition/test_cost_aware.py b/test/acquisition/test_cost_aware.py index 3184183d46..a31829d81d 100644 --- a/test/acquisition/test_cost_aware.py +++ b/test/acquisition/test_cost_aware.py @@ -155,9 +155,6 @@ def cost_fn(X): ) # test eval_mask where not all rows are the same eval_mask[0, 1] = False - msg = ( - "Currently, all candidates must be evaluated " - "on the same outputs." - ) + msg = "Currently, all candidates must be evaluated on the same outputs." with self.assertRaisesRegex(NotImplementedError, msg): icwu(X, deltas, X_evaluation_mask=eval_mask) diff --git a/test/acquisition/test_input_constructors.py b/test/acquisition/test_input_constructors.py index 6301901a07..077bde807f 100644 --- a/test/acquisition/test_input_constructors.py +++ b/test/acquisition/test_input_constructors.py @@ -14,7 +14,6 @@ import math from collections.abc import Callable from functools import reduce - from random import randint from unittest import mock from unittest.mock import MagicMock @@ -54,7 +53,6 @@ qKnowledgeGradient, qMultiFidelityKnowledgeGradient, ) - from botorch.acquisition.logei import ( qLogExpectedImprovement, qLogNoisyExpectedImprovement, @@ -83,7 +81,6 @@ qHypervolumeKnowledgeGradient, qMultiFidelityHypervolumeKnowledgeGradient, ) - from botorch.acquisition.multi_objective.logei import ( qLogExpectedHypervolumeImprovement, qLogNoisyExpectedHypervolumeImprovement, @@ -716,8 +713,7 @@ def test_construct_inputs_LogPOF(self) -> None: # test that constraints on multiple outcomes raises an exception with self.assertRaisesRegex( BotorchError, - "LogProbabilityOfFeasibility only support constraints on single" - " outcomes.", + "LogProbabilityOfFeasibility only support constraints on single outcomes.", ): c( model=mock_model, diff --git a/test/acquisition/test_logei.py b/test/acquisition/test_logei.py index 09bd67d253..bff7353ba8 100644 --- a/test/acquisition/test_logei.py +++ b/test/acquisition/test_logei.py @@ -32,7 +32,6 @@ from botorch.acquisition.multi_objective.logei import ( qLogNoisyExpectedHypervolumeImprovement, ) - from botorch.acquisition.objective import ( ConstrainedMCObjective, GenericMCObjective, diff --git a/test/acquisition/test_objective.py b/test/acquisition/test_objective.py index be4101db6a..31a3093f6f 100644 --- a/test/acquisition/test_objective.py +++ b/test/acquisition/test_objective.py @@ -31,7 +31,6 @@ from botorch.utils.testing import BotorchTestCase, get_test_posterior from gpytorch.distributions import MultitaskMultivariateNormal, MultivariateNormal from linear_operator.operators.dense_linear_operator import to_linear_operator - from torch import Tensor diff --git a/test/acquisition/test_thompson_sampling.py b/test/acquisition/test_thompson_sampling.py index 54619ce5b2..b3e581dfa1 100644 --- a/test/acquisition/test_thompson_sampling.py +++ b/test/acquisition/test_thompson_sampling.py @@ -5,7 +5,6 @@ # LICENSE file in the root directory of this source tree. from itertools import product - from unittest import mock from unittest.mock import PropertyMock diff --git a/test/acquisition/test_utils.py b/test/acquisition/test_utils.py index f071545de4..7e967550fd 100644 --- a/test/acquisition/test_utils.py +++ b/test/acquisition/test_utils.py @@ -342,7 +342,7 @@ def test_project_to_target_fidelity(self): self.assertTrue(torch.equal(X_proj[..., :, [0]], 0.1 * ones)) self.assertTrue(torch.equal(X_proj[..., :, [2]], 0.5 * ones)) # test unexpected shape - msg = "X must have a last dimension with size `d` or `d-d_f`," " but got 3." + msg = "X must have a last dimension with size `d` or `d-d_f`, but got 3." with self.assertRaisesRegex(BotorchTensorDimensionError, msg): project_to_target_fidelity( X[..., :3], target_fidelities=target_fids, d=4 diff --git a/test/exceptions/test_errors.py b/test/exceptions/test_errors.py index 321a0e4a3f..a8f4494359 100644 --- a/test/exceptions/test_errors.py +++ b/test/exceptions/test_errors.py @@ -5,7 +5,6 @@ # LICENSE file in the root directory of this source tree. import numpy as np - from botorch.exceptions.errors import ( BotorchError, BotorchTensorDimensionError, diff --git a/test/generation/test_gen.py b/test/generation/test_gen.py index b847934942..d01645feec 100644 --- a/test/generation/test_gen.py +++ b/test/generation/test_gen.py @@ -274,18 +274,20 @@ def test_gen_candidates_scipy_warns_opt_failure(self): def test_gen_candidates_scipy_maxiter_behavior(self): # Check that no warnings are raised & log produced on hitting maxiter. for method in ("SLSQP", "L-BFGS-B"): - with warnings.catch_warnings(record=True) as ws, self.assertLogs( - "botorch", level="INFO" - ) as logs: + with ( + warnings.catch_warnings(record=True) as ws, + self.assertLogs("botorch", level="INFO") as logs, + ): self.test_gen_candidates(options={"maxiter": 1, "method": method}) self.assertFalse( any(issubclass(w.category, OptimizationWarning) for w in ws) ) self.assertTrue("iteration limit" in logs.output[-1]) # Check that we handle maxfun as well. - with warnings.catch_warnings(record=True) as ws, self.assertLogs( - "botorch", level="INFO" - ) as logs: + with ( + warnings.catch_warnings(record=True) as ws, + self.assertLogs("botorch", level="INFO") as logs, + ): self.test_gen_candidates( options={"maxiter": 100, "maxfun": 1, "method": "L-BFGS-B"} ) @@ -295,9 +297,10 @@ def test_gen_candidates_scipy_maxiter_behavior(self): def test_gen_candidates_scipy_timeout_behavior(self): # Check that no warnings are raised & log produced on hitting timeout. for method in ("SLSQP", "L-BFGS-B"): - with warnings.catch_warnings(record=True) as ws, self.assertLogs( - "botorch", level="INFO" - ) as logs: + with ( + warnings.catch_warnings(record=True) as ws, + self.assertLogs("botorch", level="INFO") as logs, + ): self.test_gen_candidates(options={"method": method}, timeout_sec=0.001) self.assertFalse( any(issubclass(w.category, OptimizationWarning) for w in ws) @@ -315,9 +318,10 @@ def test_gen_candidates_throws_error_when_forcing_parallel_and_timeout(self): def test_gen_candidates_torch_timeout_behavior(self): # Check that no warnings are raised & log produced on hitting timeout. - with warnings.catch_warnings(record=True) as ws, self.assertLogs( - "botorch", level="INFO" - ) as logs: + with ( + warnings.catch_warnings(record=True) as ws, + self.assertLogs("botorch", level="INFO") as logs, + ): self.test_gen_candidates( gen_candidates=gen_candidates_torch, timeout_sec=0.001 ) @@ -381,9 +385,10 @@ def test_gen_candidates_scipy_warns_opt_no_res(self): "Optimization failed within `scipy.optimize.minimize` with no " "status returned to `res.`" ) - with mock.patch( - "botorch.generation.gen.minimize_with_timeout" - ) as mock_minimize, warnings.catch_warnings(record=True) as ws: + with ( + mock.patch("botorch.generation.gen.minimize_with_timeout") as mock_minimize, + warnings.catch_warnings(record=True) as ws, + ): mock_minimize.return_value = OptimizeResult(x=test_ics.cpu().numpy()) gen_candidates_scipy( diff --git a/test/generation/test_utils.py b/test/generation/test_utils.py index 6f188bb262..e265e938d6 100644 --- a/test/generation/test_utils.py +++ b/test/generation/test_utils.py @@ -9,7 +9,6 @@ from itertools import product import torch - from botorch.acquisition import FixedFeatureAcquisitionFunction from botorch.generation.utils import ( _flip_sub_unique, diff --git a/test/models/kernels/test_contextual.py b/test/models/kernels/test_contextual.py index 6647548ced..e4c9a55c07 100644 --- a/test/models/kernels/test_contextual.py +++ b/test/models/kernels/test_contextual.py @@ -11,7 +11,6 @@ is_contiguous, LCEAKernel, ) - from botorch.models.kernels.contextual_sac import SACKernel from botorch.utils.testing import BotorchTestCase from gpytorch.kernels.rbf_kernel import RBFKernel diff --git a/test/models/test_deterministic.py b/test/models/test_deterministic.py index b9d785ad84..9ac4c71f4f 100644 --- a/test/models/test_deterministic.py +++ b/test/models/test_deterministic.py @@ -7,7 +7,6 @@ import torch from botorch.acquisition.objective import ScalarizedPosteriorTransform - from botorch.exceptions.errors import UnsupportedError from botorch.models import SingleTaskGP from botorch.models.deterministic import ( diff --git a/test/models/test_fully_bayesian.py b/test/models/test_fully_bayesian.py index 2882e6f194..2d54e6a4e1 100644 --- a/test/models/test_fully_bayesian.py +++ b/test/models/test_fully_bayesian.py @@ -10,7 +10,6 @@ from unittest.mock import patch import pyro - import torch from botorch import fit_fully_bayesian_model_nuts, utils from botorch.acquisition.analytic import ( diff --git a/test/models/test_fully_bayesian_multitask.py b/test/models/test_fully_bayesian_multitask.py index d6d2111e99..7dc2473d9a 100644 --- a/test/models/test_fully_bayesian_multitask.py +++ b/test/models/test_fully_bayesian_multitask.py @@ -24,7 +24,6 @@ qSimpleRegret, qUpperConfidenceBound, ) - from botorch.acquisition.multi_objective.logei import ( qLogExpectedHypervolumeImprovement, qLogNoisyExpectedHypervolumeImprovement, diff --git a/test/models/test_gpytorch.py b/test/models/test_gpytorch.py index ff92d15ada..293e22f4e9 100644 --- a/test/models/test_gpytorch.py +++ b/test/models/test_gpytorch.py @@ -46,7 +46,6 @@ from gpytorch.models import ExactGP, IndependentModelList from gpytorch.settings import trace_mode from torch import Tensor - from torch.nn.functional import one_hot diff --git a/test/models/test_map_saas.py b/test/models/test_map_saas.py index d001718cb0..6bc6fbcc67 100644 --- a/test/models/test_map_saas.py +++ b/test/models/test_map_saas.py @@ -300,9 +300,10 @@ def test_get_saas_model(self) -> None: def test_get_saas_ensemble(self) -> None: train_X, train_Y, _ = self._get_data_hardcoded(device=self.device) - with self.assertWarnsRegex( - DeprecationWarning, "EnsembleMapSaasSingleTaskGP" - ), mock.patch("botorch.fit.fit_gpytorch_mll") as mock_fit: + with ( + self.assertWarnsRegex(DeprecationWarning, "EnsembleMapSaasSingleTaskGP"), + mock.patch("botorch.fit.fit_gpytorch_mll") as mock_fit, + ): model = get_fitted_map_saas_ensemble( train_X=train_X, train_Y=train_Y, diff --git a/test/models/test_model.py b/test/models/test_model.py index 273e60887e..e7ff60746b 100644 --- a/test/models/test_model.py +++ b/test/models/test_model.py @@ -60,8 +60,12 @@ def test_not_so_abstract_base_model(self): def test_construct_inputs(self) -> None: model = NotSoAbstractBaseModel() - with self.subTest("Wrong training data type"), self.assertRaisesRegex( - TypeError, "Expected `training_data` to be a `SupervisedDataset`, but got " + with ( + self.subTest("Wrong training data type"), + self.assertRaisesRegex( + TypeError, + "Expected `training_data` to be a `SupervisedDataset`, but got ", + ), ): model.construct_inputs(training_data=None) diff --git a/test/models/test_relevance_pursuit.py b/test/models/test_relevance_pursuit.py index 082d6a911e..f62c8dbe96 100644 --- a/test/models/test_relevance_pursuit.py +++ b/test/models/test_relevance_pursuit.py @@ -8,7 +8,6 @@ import itertools import warnings - from functools import partial from unittest.mock import patch @@ -35,12 +34,10 @@ ) from botorch.models.transforms.input import Normalize from botorch.test_functions.base import constant_outlier_generator, CorruptedTestProblem - from botorch.test_functions.synthetic import Ackley from botorch.utils.constraints import NonTransformedInterval from botorch.utils.testing import BotorchTestCase from gpytorch.constraints import Interval - from gpytorch.kernels import RBFKernel, ScaleKernel from gpytorch.likelihoods.noise_models import HomoskedasticNoise from gpytorch.means import ZeroMean diff --git a/test/models/utils/test_assorted.py b/test/models/utils/test_assorted.py index e682234759..410f0a3d41 100644 --- a/test/models/utils/test_assorted.py +++ b/test/models/utils/test_assorted.py @@ -19,7 +19,6 @@ multioutput_to_batch_mode_transform, validate_input_scaling, ) - from botorch.models.utils.assorted import consolidate_duplicates, detect_duplicates from botorch.utils.testing import BotorchTestCase from gpytorch import settings as gpt_settings @@ -173,9 +172,10 @@ def test_validate_input_scaling(self): train_X = 2 + torch.rand(3, 4, 3) train_Y = torch.randn(3, 4, 2) # check that nothing is being checked - with settings.validate_input_scaling(False), warnings.catch_warnings( - record=True - ) as ws: + with ( + settings.validate_input_scaling(False), + warnings.catch_warnings(record=True) as ws, + ): validate_input_scaling(train_X=train_X, train_Y=train_Y) self.assertFalse(any(issubclass(w.category, InputDataWarning) for w in ws)) # check that warnings are being issued diff --git a/test/models/utils/test_inducing_point_allocators.py b/test/models/utils/test_inducing_point_allocators.py index dd1e047c49..5a0c09f2b3 100644 --- a/test/models/utils/test_inducing_point_allocators.py +++ b/test/models/utils/test_inducing_point_allocators.py @@ -17,7 +17,6 @@ UnitQualityFunction, ) from botorch.utils.testing import BotorchTestCase - from gpytorch.kernels import MaternKernel, ScaleKernel from gpytorch.likelihoods import GaussianLikelihood from gpytorch.mlls import VariationalELBO diff --git a/test/optim/test_batched_lbfgs_b.py b/test/optim/test_batched_lbfgs_b.py index f58c3f357a..efc742f58b 100644 --- a/test/optim/test_batched_lbfgs_b.py +++ b/test/optim/test_batched_lbfgs_b.py @@ -10,7 +10,6 @@ fmin_l_bfgs_b_batched, translate_bounds_for_lbfgsb, ) - from botorch.utils.testing import BotorchTestCase diff --git a/test/optim/test_fit.py b/test/optim/test_fit.py index 50491832eb..7c594afd57 100644 --- a/test/optim/test_fit.py +++ b/test/optim/test_fit.py @@ -103,9 +103,10 @@ def _test_fit_gpytorch_mll_scipy(self, mll): values = assignments[name] = torch.rand_like(param) mock_x.append(values.view(-1)) - with module_rollback_ctx(mll, checkpoint=ckpt), patch.object( - core, "minimize_with_timeout" - ) as mock_minimize_with_timeout: + with ( + module_rollback_ctx(mll, checkpoint=ckpt), + patch.object(core, "minimize_with_timeout") as mock_minimize_with_timeout, + ): mock_minimize_with_timeout.return_value = OptimizeResult( x=torch.concat(mock_x).tolist(), success=False, diff --git a/test/optim/test_initializers.py b/test/optim/test_initializers.py index 83d75cd27b..521d924d49 100644 --- a/test/optim/test_initializers.py +++ b/test/optim/test_initializers.py @@ -241,11 +241,14 @@ def test_gen_batch_initial_conditions(self): bounds = bounds.to(device=self.device, dtype=dtype) mock_acqf.X_baseline = bounds # for testing sample_around_best mock_acqf.model = MockModel(MockPosterior(mean=bounds[:, :1])) - with mock.patch.object( - MockAcquisitionFunction, - "__call__", - wraps=mock_acqf.__call__, - ) as mock_acqf_call, warnings.catch_warnings(): + with ( + mock.patch.object( + MockAcquisitionFunction, + "__call__", + wraps=mock_acqf.__call__, + ) as mock_acqf_call, + warnings.catch_warnings(), + ): warnings.simplefilter("ignore", category=BadInitialCandidatesWarning) batch_initial_conditions = gen_batch_initial_conditions( acq_function=mock_acqf, @@ -318,11 +321,14 @@ def test_gen_batch_initial_conditions_topn(self): bounds = bounds.to(device=self.device, dtype=dtype) mock_acqf.X_baseline = bounds # for testing sample_around_best mock_acqf.model = MockModel(MockPosterior(mean=bounds[:, :1])) - with mock.patch.object( - MockAcquisitionFunction, - "__call__", - wraps=mock_acqf.__call__, - ) as mock_acqf_call, warnings.catch_warnings(): + with ( + mock.patch.object( + MockAcquisitionFunction, + "__call__", + wraps=mock_acqf.__call__, + ) as mock_acqf_call, + warnings.catch_warnings(), + ): warnings.simplefilter("ignore", category=BadInitialCandidatesWarning) options = { "topn": topn, @@ -421,12 +427,15 @@ def test_gen_batch_initial_conditions_warning(self) -> None: for dtype in (torch.float, torch.double): bounds = torch.tensor([[0, 0], [1, 1]], device=self.device, dtype=dtype) samples = torch.zeros(10, 1, 2, device=self.device, dtype=dtype) - with self.assertWarnsRegex( - expected_warning=BadInitialCandidatesWarning, - expected_regex="Unable to find non-zero acquisition", - ), mock.patch( - "botorch.optim.initializers.draw_sobol_samples", - return_value=samples, + with ( + self.assertWarnsRegex( + expected_warning=BadInitialCandidatesWarning, + expected_regex="Unable to find non-zero acquisition", + ), + mock.patch( + "botorch.optim.initializers.draw_sobol_samples", + return_value=samples, + ), ): batch_initial_conditions = gen_batch_initial_conditions( acq_function=MockAcquisitionFunction(), @@ -677,11 +686,14 @@ def test_gen_batch_initial_conditions_constraints(self): [True, False], [None, 1234], [None, 1], [None, {0: 0.5}] ): mock_acqf = MockAcquisitionFunction() - with mock.patch.object( - MockAcquisitionFunction, - "__call__", - wraps=mock_acqf.__call__, - ) as mock_acqf_call, warnings.catch_warnings(): + with ( + mock.patch.object( + MockAcquisitionFunction, + "__call__", + wraps=mock_acqf.__call__, + ) as mock_acqf_call, + warnings.catch_warnings(), + ): warnings.simplefilter( "ignore", category=BadInitialCandidatesWarning ) @@ -856,11 +868,14 @@ def generator(n: int, q: int, seed: int | None): return X_rnd mock_acqf = MockAcquisitionFunction() - with mock.patch.object( - MockAcquisitionFunction, - "__call__", - wraps=mock_acqf.__call__, - ), warnings.catch_warnings(): + with ( + mock.patch.object( + MockAcquisitionFunction, + "__call__", + wraps=mock_acqf.__call__, + ), + warnings.catch_warnings(), + ): warnings.simplefilter( "ignore", category=BadInitialCandidatesWarning ) @@ -1061,13 +1076,14 @@ def test_gen_one_shot_kg_initial_conditions(self): ) ] } - with self.subTest( - f"intra-point {constraint_type} not supported" - ), self.assertRaisesRegex( - NotImplementedError, - "Indices must be one-dimensional " - "in gen_one_shot_kg_initial_conditions. " - "Received indices", + with ( + self.subTest(f"intra-point {constraint_type} not supported"), + self.assertRaisesRegex( + NotImplementedError, + "Indices must be one-dimensional " + "in gen_one_shot_kg_initial_conditions. " + "Received indices", + ), ): gen_one_shot_kg_initial_conditions( acq_function=mock_kg, diff --git a/test/optim/test_optimize_mixed.py b/test/optim/test_optimize_mixed.py index 7f6878ada4..9b2ac0644f 100644 --- a/test/optim/test_optimize_mixed.py +++ b/test/optim/test_optimize_mixed.py @@ -1477,9 +1477,12 @@ def org_post_proc_func(X: Tensor) -> Tensor: return X # The key test is that this call doesn't error out. - with mock.patch( - "botorch.optim.optimize_mixed._optimize_acqf", wraps=_optimize_acqf - ) as mock_opt, warnings.catch_warnings(record=True) as ws: + with ( + mock.patch( + "botorch.optim.optimize_mixed._optimize_acqf", wraps=_optimize_acqf + ) as mock_opt, + warnings.catch_warnings(record=True) as ws, + ): X, _ = generate_starting_points( opt_inputs=_make_opt_inputs( acq_function=qLogNoisyExpectedImprovement( diff --git a/test/sampling/pathwise/features/test_generators.py b/test/sampling/pathwise/features/test_generators.py index 2062d09a40..1548313c67 100644 --- a/test/sampling/pathwise/features/test_generators.py +++ b/test/sampling/pathwise/features/test_generators.py @@ -94,10 +94,13 @@ def _test_gen_kernel_features( ) # Test passing the wrong dimensional shape to `weight_generator` - with self.assertRaisesRegex(UnsupportedError, "2-dim"), patch.object( - generators, - "_gen_fourier_features", - side_effect=lambda **kwargs: kwargs["weight_generator"](Size([])), + with ( + self.assertRaisesRegex(UnsupportedError, "2-dim"), + patch.object( + generators, + "_gen_fourier_features", + side_effect=lambda **kwargs: kwargs["weight_generator"](Size([])), + ), ): gen_kernel_features( kernel=kernel, diff --git a/test/sampling/pathwise/test_posterior_samplers.py b/test/sampling/pathwise/test_posterior_samplers.py index b182612493..69abd650a2 100644 --- a/test/sampling/pathwise/test_posterior_samplers.py +++ b/test/sampling/pathwise/test_posterior_samplers.py @@ -23,7 +23,6 @@ get_sample_moments, standardize_moments, ) - from botorch.utils.testing import BotorchTestCase from botorch.utils.transforms import is_ensemble from gpytorch.kernels import MaternKernel, ScaleKernel diff --git a/test/sampling/pathwise/test_update_strategies.py b/test/sampling/pathwise/test_update_strategies.py index 7a4d7ad334..f40d547ee5 100644 --- a/test/sampling/pathwise/test_update_strategies.py +++ b/test/sampling/pathwise/test_update_strategies.py @@ -133,10 +133,13 @@ def _test_gaussian_updates(self, model): ) # Disable sampling of noise variables `e` used to obtain `y = f + e` - with delattr_ctx(model, "outcome_transform"), patch.object( - torch, - "randn_like", - return_value=noise_values, + with ( + delattr_ctx(model, "outcome_transform"), + patch.object( + torch, + "randn_like", + return_value=noise_values, + ), ): prior_paths = draw_kernel_feature_paths(model, sample_shape=sample_shape) sample_values = prior_paths(X) diff --git a/test/sampling/pathwise/test_utils.py b/test/sampling/pathwise/test_utils.py index 31489ceb17..8e165db535 100644 --- a/test/sampling/pathwise/test_utils.py +++ b/test/sampling/pathwise/test_utils.py @@ -105,8 +105,9 @@ def test_get_train_inputs(self): model.eval() self.assertTrue(X.equal(get_train_inputs(model, transformed=False)[0])) self.assertTrue(Z.equal(get_train_inputs(model, transformed=True)[0])) - with delattr_ctx(model, "input_transform"), patch.object( - model, "_original_train_inputs", new=None + with ( + delattr_ctx(model, "input_transform"), + patch.object(model, "_original_train_inputs", new=None), ): self.assertTrue(Z.equal(get_train_inputs(model, transformed=False)[0])) self.assertTrue(Z.equal(get_train_inputs(model, transformed=True)[0])) diff --git a/test/sampling/test_list_sampler.py b/test/sampling/test_list_sampler.py index 8140e7e6dc..fd9cf9e002 100644 --- a/test/sampling/test_list_sampler.py +++ b/test/sampling/test_list_sampler.py @@ -50,11 +50,10 @@ def test_list_sampler(self): IIDNormalSampler(sample_shape=torch.Size([2])), SobolQMCNormalSampler(sample_shape=torch.Size([2])), ) - with mock.patch.object( - sampler.samplers[0], "_update_base_samples" - ) as update_0, mock.patch.object( - sampler.samplers[1], "_update_base_samples" - ) as update_1: + with ( + mock.patch.object(sampler.samplers[0], "_update_base_samples") as update_0, + mock.patch.object(sampler.samplers[1], "_update_base_samples") as update_1, + ): sampler._update_base_samples(posterior=p_list, base_sampler=sampler2) update_0.assert_called_once_with( posterior=p1, base_sampler=sampler2.samplers[0] diff --git a/test/test_logging.py b/test/test_logging.py index 3f654b70cc..c3c3fc3bb5 100644 --- a/test/test_logging.py +++ b/test/test_logging.py @@ -7,7 +7,6 @@ import logging import torch - from botorch import settings from botorch.logging import LOG_LEVEL_DEFAULT, logger, shape_to_str from botorch.utils.testing import BotorchTestCase diff --git a/test/utils/multi_objective/box_decompositions/test_box_decomposition.py b/test/utils/multi_objective/box_decompositions/test_box_decomposition.py index a4bb368fc5..6f9768419e 100644 --- a/test/utils/multi_objective/box_decompositions/test_box_decomposition.py +++ b/test/utils/multi_objective/box_decompositions/test_box_decomposition.py @@ -239,17 +239,21 @@ def test_fast_partitioning(self): # test that update_local_upper_bounds_incremental is called when m>2 bd = DummyFastPartitioning(ref_point=ref_point) - with mock.patch( - "botorch.utils.multi_objective.box_decompositions.box_decomposition." - "update_local_upper_bounds_incremental", - wraps=update_local_upper_bounds_incremental, - ) as mock_update_local_upper_bounds_incremental, mock.patch.object( - DummyFastPartitioning, - "_get_partitioning", - wraps=bd._get_partitioning, - ) as mock_get_partitioning, mock.patch.object( - DummyFastPartitioning, - "_partition_space_2d", + with ( + mock.patch( + "botorch.utils.multi_objective.box_decompositions." + "box_decomposition.update_local_upper_bounds_incremental", + wraps=update_local_upper_bounds_incremental, + ) as mock_update_local_upper_bounds_incremental, + mock.patch.object( + DummyFastPartitioning, + "_get_partitioning", + wraps=bd._get_partitioning, + ) as mock_get_partitioning, + mock.patch.object( + DummyFastPartitioning, + "_partition_space_2d", + ), ): bd.update(Y=Y) if m > 2: diff --git a/test/utils/probability/test_bvn.py b/test/utils/probability/test_bvn.py index bc2bf1f566..8acac6f820 100644 --- a/test/utils/probability/test_bvn.py +++ b/test/utils/probability/test_bvn.py @@ -7,7 +7,6 @@ from __future__ import annotations from collections.abc import Callable - from itertools import count from typing import Any diff --git a/test/utils/probability/test_lin_ess.py b/test/utils/probability/test_lin_ess.py index 29a7ed3ed4..8d80e012e7 100644 --- a/test/utils/probability/test_lin_ess.py +++ b/test/utils/probability/test_lin_ess.py @@ -7,9 +7,7 @@ from __future__ import annotations import itertools - import math - from unittest.mock import patch import torch diff --git a/test/utils/probability/test_mvnxpb.py b/test/utils/probability/test_mvnxpb.py index c96e946fc6..cad02f4f91 100644 --- a/test/utils/probability/test_mvnxpb.py +++ b/test/utils/probability/test_mvnxpb.py @@ -7,9 +7,7 @@ from __future__ import annotations from collections.abc import Callable, Sequence - from copy import deepcopy - from functools import partial from itertools import count, product from typing import Any @@ -277,8 +275,9 @@ def test_augment(self): augm_perm = augm.perm temp_perm = perm.gather(-1, augm_perm) self.assertTrue(augm_perm.equal(augm.piv_chol.perm)) - with patch.object(augm, "perm", new=temp_perm), patch.object( - augm.piv_chol, "perm", new=temp_perm + with ( + patch.object(augm, "perm", new=temp_perm), + patch.object(augm.piv_chol, "perm", new=temp_perm), ): self.assertEqualMXNBPB(full, augm) @@ -292,8 +291,9 @@ def test_augment(self): augm_perm = augm.perm temp_perm = perm.gather(-1, augm_perm) self.assertTrue(augm_perm.equal(augm.piv_chol.perm)) - with patch.object(augm, "perm", new=temp_perm), patch.object( - augm.piv_chol, "perm", new=temp_perm + with ( + patch.object(augm, "perm", new=temp_perm), + patch.object(augm.piv_chol, "perm", new=temp_perm), ): self.assertEqualMXNBPB(full, augm) @@ -354,8 +354,11 @@ def test_concat(self): self.assertEqualMXNBPB(self.toy_solver, other) # Test exception handling - with patch.object(A, "step", new=A.step + 1), self.assertRaisesRegex( - ValueError, "`self.step` does not equal `other.step`." + with ( + patch.object(A, "step", new=A.step + 1), + self.assertRaisesRegex( + ValueError, "`self.step` does not equal `other.step`." + ), ): A.concat(B, dim=0) @@ -365,8 +368,11 @@ def test_concat(self): with self.assertRaisesRegex(ValueError, "not a valid batch dimension"): A.concat(B, dim=-9) - with patch.object(A, "plug_ins", new=None), self.assertRaisesRegex( - TypeError, "Concatenation failed: `self.plug_ins` has type" + with ( + patch.object(A, "plug_ins", new=None), + self.assertRaisesRegex( + TypeError, "Concatenation failed: `self.plug_ins` has type" + ), ): A.concat(B, dim=0) diff --git a/test/utils/probability/test_truncated_multivariate_normal.py b/test/utils/probability/test_truncated_multivariate_normal.py index c96cf022bd..cc1b3b8ce7 100644 --- a/test/utils/probability/test_truncated_multivariate_normal.py +++ b/test/utils/probability/test_truncated_multivariate_normal.py @@ -7,7 +7,6 @@ from __future__ import annotations from collections.abc import Sequence - from itertools import count import torch diff --git a/test/utils/probability/test_unified_skew_normal.py b/test/utils/probability/test_unified_skew_normal.py index f2ab236a8c..f74229422c 100644 --- a/test/utils/probability/test_unified_skew_normal.py +++ b/test/utils/probability/test_unified_skew_normal.py @@ -7,11 +7,8 @@ from __future__ import annotations from collections.abc import Sequence - from copy import deepcopy - from itertools import count - from typing import Any import torch diff --git a/test/utils/probability/test_utils.py b/test/utils/probability/test_utils.py index 55ba257e5b..db8ee1b2e7 100644 --- a/test/utils/probability/test_utils.py +++ b/test/utils/probability/test_utils.py @@ -9,7 +9,6 @@ import itertools import numpy as np - import torch from botorch.utils.probability import ndtr, utils from botorch.utils.probability.utils import ( diff --git a/test/utils/test_safe_math.py b/test/utils/test_safe_math.py index 35389dceaf..0703446933 100644 --- a/test/utils/test_safe_math.py +++ b/test/utils/test_safe_math.py @@ -7,7 +7,6 @@ from __future__ import annotations import itertools - import math from abc import abstractmethod from collections.abc import Callable diff --git a/test/utils/test_test_helpers.py b/test/utils/test_test_helpers.py index f65095bcde..351480cc3f 100644 --- a/test/utils/test_test_helpers.py +++ b/test/utils/test_test_helpers.py @@ -7,7 +7,6 @@ from unittest import mock from botorch.exceptions import UnsupportedError - from botorch.utils.test_helpers import get_pvar_expected from botorch.utils.testing import BotorchTestCase diff --git a/test_community/models/test_gp_regression_multisource.py b/test_community/models/test_gp_regression_multisource.py index 1c97416e7f..c1abea1f43 100644 --- a/test_community/models/test_gp_regression_multisource.py +++ b/test_community/models/test_gp_regression_multisource.py @@ -9,7 +9,6 @@ import warnings import torch - from botorch import fit_gpytorch_mll from botorch.exceptions import InputDataError, OptimizationWarning from botorch.models import SingleTaskGP diff --git a/test_community/models/test_vbll_helper.py b/test_community/models/test_vbll_helper.py index f390b5e9c8..52d92b331b 100644 --- a/test_community/models/test_vbll_helper.py +++ b/test_community/models/test_vbll_helper.py @@ -5,7 +5,6 @@ # LICENSE file in the root directory of this source tree. import torch - from botorch.utils.testing import BotorchTestCase from botorch_community.models.vbll_helper import ( DenseNormal, diff --git a/test_community/models/test_vblls.py b/test_community/models/test_vblls.py index ba07319fee..7966b7b486 100644 --- a/test_community/models/test_vblls.py +++ b/test_community/models/test_vblls.py @@ -9,7 +9,6 @@ import numpy as np import torch - from botorch.utils.testing import BotorchTestCase from botorch_community.models.blls import AbstractBLLModel from botorch_community.models.vblls import VBLLModel diff --git a/test_community/posteriors/test_bll.py b/test_community/posteriors/test_bll.py index dfb92660d5..f0d2488bce 100644 --- a/test_community/posteriors/test_bll.py +++ b/test_community/posteriors/test_bll.py @@ -5,7 +5,6 @@ # LICENSE file in the root directory of this source tree. import torch - from botorch.utils.testing import BotorchTestCase from botorch_community.models.vblls import VBLLModel from botorch_community.posteriors.bll_posterior import BLLPosterior