@@ -400,11 +400,12 @@ cpdef void do_line_search(
400
400
floating[::1 , :] X, floating[:] X_data,
401
401
int [:] X_indices, int [:] X_indptr, int MAX_BACKTRACK_ITR,
402
402
floating[:] y, floating[:] exp_Xw, floating[:] low_exp_Xw,
403
- floating[:] aux, int [:] is_positive_label) nogil :
403
+ floating[:] aux, int [:] is_positive_label):
404
404
405
405
cdef int i, ind, backtrack_itr
406
406
cdef floating deriv
407
407
cdef floating step_size = 1.
408
+ cdef floating atol = 1e-7
408
409
409
410
cdef int n_samples = y.shape[0 ]
410
411
fcopy(& n_samples, & exp_Xw[0 ], & inc, & low_exp_Xw[0 ], & inc)
@@ -417,15 +418,18 @@ cpdef void do_line_search(
417
418
deriv = compute_derivative(
418
419
w, WS, delta_w, X_delta_w, alpha, aux, step_size, y)
419
420
420
- if deriv < 1e-7 :
421
+ if deriv < atol :
421
422
break
422
423
else :
423
424
step_size = step_size / 2.
424
425
for i in range (n_samples):
425
426
exp_Xw[i] = sqrt(exp_Xw[i] * low_exp_Xw[i])
426
427
else :
427
- pass
428
- # TODO what do we do in this case?
428
+ warnings.warn(
429
+ ' Line search failed to converge '
430
+ f' deriv {deriv:.2e}, atol {atol:.2e}' ,
431
+ ConvergenceWarning
432
+ )
429
433
430
434
# a suitable step size is found, perform step:
431
435
for ind in range (WS.shape[0 ]):
0 commit comments