CI Fixes test_rank_deficient_design
@@ -544,6 +544,7 @@ def _lars_path_solver(
sys.stdout.flush()
tiny32 = np.finfo(np.float32).tiny # to avoid division by 0 warning
+ cov_precision = np.finfo(Cov.dtype).precision
equality_tolerance = np.finfo(np.float32).eps
if Gram is not None:
@@ -726,6 +727,10 @@ def _lars_path_solver(
# orthogonal (QR) decomposition of X
corr_eq_dir = np.dot(Gram[:n_active, n_active:].T, least_squares)
+ # Explicit rounding can be necessary to avoid `np.argmax(Cov)` yielding
+ # unstable results because of rounding errors.
+ np.around(corr_eq_dir, decimals=cov_precision, out=corr_eq_dir)
+
g1 = arrayfuncs.min_pos((C - Cov) / (AA - corr_eq_dir + tiny32))
if positive:
gamma_ = min(g1, C / AA)
