Skip to content

Commit 9157b90

Browse files
committed
Integrate comments from review
1 parent 46b5398 commit 9157b90

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/optimagic/optimization/optimize.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,6 @@ def _optimize(problem: OptimizationProblem) -> OptimizeResult:
561561
# Strict checking if bounds are required and infinite values in bounds
562562
# ==================================================================================
563563
if problem.algorithm.algo_info.supports_bounds:
564-
# NOTE: All-infinite bounds arrays are normalized to None in bounds processing,
565-
# so we only need to handle the cases: None bounds, or mixed finite/infinite
566-
# bounds
567564
bounds_missing = (
568565
internal_params.lower_bounds is None or internal_params.upper_bounds is None
569566
)

src/optimagic/parameters/scale_conversion.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,14 @@ def calculate_scaling_factor_and_offset(
117117
raw_factor = np.clip(np.abs(x), options.clipping_value, np.inf)
118118
scaling_offset = None
119119
elif options.method == "bounds":
120-
if lower_bounds is None or upper_bounds is None:
120+
if (
121+
lower_bounds is None
122+
or np.isinf(lower_bounds).any()
123+
or upper_bounds is None
124+
or np.isinf(upper_bounds).any()
125+
):
121126
raise ValueError(
122-
"Finite bounds must be provided for 'bounds' scaling method."
127+
"To use the 'bounds' scaling method, all bounds must be finite."
123128
)
124129
raw_factor = upper_bounds - lower_bounds
125130
scaling_offset = lower_bounds

0 commit comments

Comments
 (0)