Skip to content

Commit

Permalink
Ensure parameter bounds cover zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Waschenbacher committed Jan 14, 2025
1 parent 983b1a9 commit bddab62
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion baybe/constraints/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ def get_threshold(self, parameter: NumericalContinuousParameter) -> Interval:
* If lower < 0 and upper = 0, any value v with lower < v <= upper are
treated zero.
Args:
parameter: The parameter object.
Expand All @@ -229,12 +228,18 @@ def get_threshold(self, parameter: NumericalContinuousParameter) -> Interval:
Raises:
ValueError: when parameter_name is not present in parameter list of this
constraint.
ValueError: when parameter bounds do not cover zero.
"""
if parameter.name not in self.parameters:
raise ValueError(
f"The given parameter with name: {parameter.name} cannot "
f"be found in the parameter list: {self.parameters}."
)
if parameter.bounds.contains(0.0):
raise ValueError(
f"The bounds of the given parameter must cover zero but its bounds "
f"are ({parameter.bounds.lower}, {parameter.bounds.upper})."
)

return Interval(
lower=self.relative_threshold * parameter.bounds.lower,
Expand Down

0 comments on commit bddab62

Please sign in to comment.