Skip to content

Commit

Permalink
Rename custom warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Scienfitz committed Jul 2, 2024
1 parent c4b7365 commit 8885d4e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions baybe/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@


##### Warnings #####
class NonPredictiveRecommenderWarning(UserWarning):
class UnusedObjectWarning(UserWarning):
"""
A non-predictive recommender was called with undesired arguments which indicates an
A method or function was called with undesired arguments which indicates an
unintended user fault.
"""

Expand Down
6 changes: 3 additions & 3 deletions baybe/recommenders/pure/nonpredictive/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pandas as pd
from attrs import define

from baybe.exceptions import NonPredictiveRecommenderWarning
from baybe.exceptions import UnusedObjectWarning
from baybe.objectives.base import Objective
from baybe.recommenders.pure.base import PureRecommender
from baybe.searchspace.core import SearchSpace
Expand All @@ -30,14 +30,14 @@ def recommend( # noqa: D102
f"'{self.recommend.__name__}' was called with a non-empty "
f"set of measurements but '{self.__class__.__name__}' does not "
f"utilize any training data, meaning that the argument is ignored.",
NonPredictiveRecommenderWarning,
UnusedObjectWarning,
)
if objective is not None:
warnings.warn(
f"'{self.recommend.__name__}' was called with a an explicit objective "
f"but '{self.__class__.__name__}' does not "
f"consider any objectives, meaning that the argument is ignored.",
NonPredictiveRecommenderWarning,
UnusedObjectWarning,
)
return super().recommend(
batch_size=batch_size,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_iterations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from baybe.acquisition import qNIPV
from baybe.acquisition.base import AcquisitionFunction
from baybe.exceptions import NonPredictiveRecommenderWarning
from baybe.exceptions import UnusedObjectWarning
from baybe.kernels.base import Kernel
from baybe.kernels.basic import (
LinearKernel,
Expand Down Expand Up @@ -244,7 +244,7 @@ def test_iter_surrogate_model(campaign, n_iterations, batch_size):
@pytest.mark.slow
@pytest.mark.parametrize("recommender", valid_initial_recommenders)
def test_iter_initial_recommender(campaign, n_iterations, batch_size):
with pytest.warns(NonPredictiveRecommenderWarning):
with pytest.warns(UnusedObjectWarning):
run_iterations(campaign, n_iterations, batch_size)


Expand Down

0 comments on commit 8885d4e

Please sign in to comment.