|
4 | 4 | import numpy as np |
5 | 5 | from numpy import interp |
6 | 6 | import warnings |
| 7 | +import collections |
7 | 8 |
|
8 | 9 | from sklearn.base import BaseEstimator, MultiOutputMixin |
9 | 10 | from sklearn.utils.validation import (check_X_y, check_array, check_is_fitted, |
@@ -80,8 +81,9 @@ def fracridge(X, y, fracs=None, tol=1e-10, jit=True): |
80 | 81 |
|
81 | 82 | fracs : float or 1d array, optional |
82 | 83 | The desired fractions of the parameter vector length, relative to |
83 | | - OLS solution. If 1d array, the shape is (f,). |
84 | | - Default: np.arange(.1, 1.1, .1) |
| 84 | + OLS solution. If 1d array, the shape is (f,). This input is required |
| 85 | + to be sorted. Otherwise, raises ValueError. |
| 86 | + Default: np.arange(.1, 1.1, .1). |
85 | 87 |
|
86 | 88 | jit : bool, optional |
87 | 89 | Whether to speed up computations by using a just-in-time compiled |
@@ -129,7 +131,12 @@ def fracridge(X, y, fracs=None, tol=1e-10, jit=True): |
129 | 131 | if fracs is None: |
130 | 132 | fracs = np.arange(.1, 1.1, .1) |
131 | 133 |
|
132 | | - if not hasattr(fracs, "__len__"): |
| 134 | + if hasattr(fracs, "__len__"): |
| 135 | + if np.any(np.diff(fracs) < 0): |
| 136 | + raise ValueError("The `frac` inputs to the `fracridge` function ", |
| 137 | + f"must be sorted. You provided: {fracs}") |
| 138 | + |
| 139 | + else: |
133 | 140 | fracs = [fracs] |
134 | 141 | fracs = np.array(fracs) |
135 | 142 |
|
|
0 commit comments