Skip to content

Commit aec7006

Browse files
authored
Merge pull request #384 from DoubleML/sk-update-bracket-guess
Fix: Ensure coef_start is a scalar and convert bracket guesses to floats to ensure scipy compatibility
2 parents 0e758cf + 6e9431c commit aec7006

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

doubleml/utils/_estimation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,18 @@ def _predict_zero_one_propensity(learner, X):
305305

306306

307307
def _get_bracket_guess(score, coef_start, coef_bounds):
308+
# Ensure coef_start is a scalar (handles 1-element arrays from optimizers)
309+
if isinstance(coef_start, np.ndarray):
310+
coef_start = coef_start.item()
311+
308312
max_bracket_length = coef_bounds[1] - coef_bounds[0]
309313
b_guess = coef_bounds
310314
delta = 0.1
311315
s_different = False
312316
while (not s_different) & (delta <= 1.0):
313317
a = np.maximum(coef_start - delta * max_bracket_length / 2, coef_bounds[0])
314318
b = np.minimum(coef_start + delta * max_bracket_length / 2, coef_bounds[1])
315-
b_guess = (a, b)
319+
b_guess = (float(a), float(b))
316320
f_a = score(b_guess[0])
317321
f_b = score(b_guess[1])
318322
s_different = np.sign(f_a) != np.sign(f_b)

0 commit comments

Comments
 (0)