From 6e9431cba41b862e6d979cf77ab344292e7fff30 Mon Sep 17 00:00:00 2001 From: SvenKlaassen Date: Wed, 14 Jan 2026 12:45:19 +0100 Subject: [PATCH] Fix: Ensure coef_start is a scalar and convert bracket guesses to float in _get_bracket_guess function --- doubleml/utils/_estimation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doubleml/utils/_estimation.py b/doubleml/utils/_estimation.py index d548ca14..3c69d744 100644 --- a/doubleml/utils/_estimation.py +++ b/doubleml/utils/_estimation.py @@ -305,6 +305,10 @@ def _predict_zero_one_propensity(learner, X): def _get_bracket_guess(score, coef_start, coef_bounds): + # Ensure coef_start is a scalar (handles 1-element arrays from optimizers) + if isinstance(coef_start, np.ndarray): + coef_start = coef_start.item() + max_bracket_length = coef_bounds[1] - coef_bounds[0] b_guess = coef_bounds delta = 0.1 @@ -312,7 +316,7 @@ def _get_bracket_guess(score, coef_start, coef_bounds): while (not s_different) & (delta <= 1.0): a = np.maximum(coef_start - delta * max_bracket_length / 2, coef_bounds[0]) b = np.minimum(coef_start + delta * max_bracket_length / 2, coef_bounds[1]) - b_guess = (a, b) + b_guess = (float(a), float(b)) f_a = score(b_guess[0]) f_b = score(b_guess[1]) s_different = np.sign(f_a) != np.sign(f_b)