Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Standardize.load_state_dict #2322

Closed
wants to merge 2 commits into from
Closed
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: 0 additions & 8 deletions botorch/models/transforms/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,6 @@ def __init__(
transform_on_fantasize: bool = True,
approximate: bool = False,
tau: float = 1e-3,
**kwargs,
) -> None:
r"""Initialize transform.

Expand All @@ -800,13 +799,6 @@ def __init__(
rounding should be used. Default: False.
tau: The temperature parameter for approximate rounding.
"""
indices = kwargs.get("indices")
if indices is not None:
warn(
"`indices` is marked for deprecation in favor of `integer_indices`.",
DeprecationWarning,
)
integer_indices = indices
if approximate and categorical_features is not None:
raise NotImplementedError
super().__init__()
Expand Down
17 changes: 1 addition & 16 deletions botorch/models/transforms/outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@

from __future__ import annotations

import warnings

from abc import ABC, abstractmethod
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple, Union
from typing import List, Optional, Tuple, Union

import torch
from botorch.models.transforms.utils import (
Expand Down Expand Up @@ -256,19 +254,6 @@ def __init__(
self._batch_shape = batch_shape
self._min_stdv = min_stdv

def load_state_dict(
self, state_dict: Mapping[str, Any], strict: bool = True
) -> None:
r"""Custom logic for loading the state dict."""
if "_is_trained" not in state_dict:
warnings.warn(
"Key '_is_trained' not found in state_dict. Setting to True. "
"In a future release, this will result in an error.",
DeprecationWarning,
)
state_dict = {**state_dict, "_is_trained": torch.tensor(True)}
super().load_state_dict(state_dict, strict=strict)

def forward(
self, Y: Tensor, Yvar: Optional[Tensor] = None
) -> Tuple[Tensor, Optional[Tensor]]:
Expand Down
6 changes: 0 additions & 6 deletions test/models/transforms/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
# LICENSE file in the root directory of this source tree.

import itertools
import warnings
from copy import deepcopy
from random import randint

import torch
from botorch import settings
from botorch.exceptions.errors import BotorchTensorDimensionError
from botorch.exceptions.warnings import UserInputWarning
from botorch.models.transforms.input import (
Expand Down Expand Up @@ -620,10 +618,6 @@ def test_round_transform_init(self) -> None:
# basic init
int_idcs = [0, 4]
categorical_feats = {2: 2, 5: 3}
# test deprecation warning
with warnings.catch_warnings(record=True) as ws, settings.debug(True):
Round(indices=int_idcs)
self.assertTrue(any(issubclass(w.category, DeprecationWarning) for w in ws))
round_tf = Round(
integer_indices=int_idcs, categorical_features=categorical_feats
)
Expand Down
7 changes: 0 additions & 7 deletions test/models/transforms/test_outcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,6 @@ def test_standardize_state_dict(self):
self.assertFalse(new_transform._is_trained)
new_transform.load_state_dict(state_dict)
self.assertTrue(new_transform._is_trained)
# test deprecation error when loading state dict without _is_trained
state_dict.pop("_is_trained")
with self.assertWarnsRegex(
DeprecationWarning,
"Key '_is_trained' not found in state_dict. Setting to True.",
):
new_transform.load_state_dict(state_dict)

def test_log(self):
ms = (1, 2)
Expand Down
Loading