Skip to content
Open
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
1 change: 0 additions & 1 deletion botorch/acquisition/analytic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from __future__ import annotations

import math

from abc import ABC, abstractmethod
from contextlib import nullcontext
from copy import deepcopy
Expand Down
1 change: 0 additions & 1 deletion botorch/acquisition/decoupled.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion botorch/acquisition/fixed_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from __future__ import annotations

from collections.abc import Sequence

from numbers import Number

import torch
Expand Down
1 change: 0 additions & 1 deletion botorch/acquisition/joint_entropy_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion botorch/acquisition/knowledge_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from __future__ import annotations

from collections.abc import Callable

from copy import deepcopy
from typing import Any

Expand Down
1 change: 0 additions & 1 deletion botorch/acquisition/max_value_entropy_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion botorch/acquisition/prior_guided.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
t_batch_mode_transform,
)
from torch import Tensor

from torch.nn import Module


Expand Down
1 change: 0 additions & 1 deletion botorch/generation/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion botorch/models/gp_regression_fidelity.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from __future__ import annotations

from collections.abc import Sequence

from typing import Any

import torch
Expand Down
1 change: 0 additions & 1 deletion botorch/models/gp_regression_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from __future__ import annotations

from collections.abc import Callable

from typing import Any

import torch
Expand Down
2 changes: 1 addition & 1 deletion botorch/models/higher_order_gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion botorch/models/kernels/orthogonal_additive_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion botorch/models/latent_kronecker_gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion botorch/models/model_list_gp_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion botorch/models/relevance_pursuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion botorch/models/robust_relevance_pursuit_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from __future__ import annotations

from abc import ABC, abstractmethod

from typing import Any, Callable, Mapping, Optional, Sequence

import torch
Expand Down
3 changes: 1 addition & 2 deletions botorch/models/transforms/outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion botorch/models/utils/inducing_point_allocators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions botorch/optim/batched_lbfgs_b.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
2 changes: 0 additions & 2 deletions botorch/optim/closures/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion botorch/optim/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion botorch/optim/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions botorch/optim/optimize_homotopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions botorch/optim/optimize_mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
2 changes: 1 addition & 1 deletion botorch/optim/utils/acquisition_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion botorch/optim/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion botorch/optim/utils/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion botorch/posteriors/fully_bayesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from __future__ import annotations

from collections.abc import Callable

from warnings import warn

import torch
Expand Down
1 change: 0 additions & 1 deletion botorch/sampling/pathwise/features/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from __future__ import annotations

from collections.abc import Callable

from typing import Any

import torch
Expand Down
1 change: 0 additions & 1 deletion botorch/sampling/pathwise/prior_samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from __future__ import annotations

from collections.abc import Callable

from typing import Any

from botorch.models.approximate_gp import ApproximateGPyTorchModel
Expand Down
3 changes: 0 additions & 3 deletions botorch/sampling/pathwise/update_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion botorch/test_functions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from __future__ import annotations

import torch

from torch import Tensor


Expand Down
1 change: 0 additions & 1 deletion botorch/test_utils/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion botorch/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from __future__ import annotations

from collections.abc import Iterator

from functools import lru_cache
from numbers import Number

Expand Down
3 changes: 0 additions & 3 deletions botorch/utils/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 0 additions & 2 deletions botorch/utils/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 0 additions & 1 deletion botorch/utils/context_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from __future__ import annotations

from collections.abc import Callable, Generator, Iterable

from contextlib import contextmanager
from typing import Any, NamedTuple

Expand Down
Loading